-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
executable file
·46 lines (39 loc) · 1.08 KB
/
installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
module_installer() {
# this module needs root/sudoer permission
#
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# create user dir for script if it does not exist
#
installer.create_dir() {
fs.create_dir_if_needed $PROG_DIR
}
# create temporary dir for script if it does not exist
#
installer.create_temp_dir() {
fs.create_dir_if_needed $PROG_TEMP_DIR
}
# creates user and adds it to sudoers list
#
installer.add_user() {
local USERNAME=$1
adduser $USERNAME
gpasswd -a $USERNAME sudo
}
# make script executable and copy to /usr/local/bin
#
installer.cp_to_bin() {
local SCRIPT=$PROG_DIR/$PROG
fs.executable_permission $SCRIPT
fs.cp $SCRIPT /usr/local/bin/
}
# compile script to C using Shell Compiler (shc)
#
installer.compile() {
local SCRIPT_NAME=$1
shc -r -f ${SCRIPT_NAME}.sh && chmod +x ${SCRIPT_NAME}.sh.x && mv ${SCRIPT_NAME}.sh.x $SCRIPT_NAME && rm ${SCRIPT_NAME}.sh.x.c
}
}