-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstaller
100 lines (84 loc) · 2.6 KB
/
installer
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
W="\033[0;37m"
G="\033[0;32m"
R="\033[0;31m"
Y="\033[0;33m"
function permission_check() {
if [ "$(id -u)" != 0 ]; then
printf "$W[$Y-$W] installer failed, are you root?\n"
exit 1
else
printf "$W[$R*$W] Welcome to the Hunter-Toolkit!\n"
sleep 1.25
fi
}
function create_command() {
if touch /bin/htkit && echo -e "#!/bin/bash\n\npython3 $PWD/htkit" > /bin/htkit; then
printf "$W[$R*$W] created bin entry successfully\n"
else
printf "$W[$Y-$W] installer failed, implementation failed on bash file creation\n"
exit 1
fi
if ! chmod +x /bin/htkit; then
printf "$W[$Y-$W] installer failed, cannot make htkit executable\n"
exit 1
else
printf "$W[$R*$W] chmod succeed\n"
fi
printf "$W[$G+$W] done\n"
}
function install_requirements() {
if ! command -v pip &> /dev/null; then
sudo apt-get update && sudo apt-get install -y python3 python3-pip
fi
if [ -f "htkit/requirements.txt" ]; then
if pip install -r htkit/requirements.txt &> /dev/null; then
printf "$W[$G+$W] requirements installed successfully\n"
else
printf "$W[$Y-$W] installer failed, cannot install the requirements\n"
exit 1
fi
elif [ -f "requirements.txt" ]; then
if pip install -r requirements.txt &> /dev/null; then
printf "$W[$G+$W] requirements installed successfully\n"
else
printf "$W[$Y-$W] installer failed, cannot install the requirements\n"
exit 1
fi
fi
printf "$W[$G+$W] done\n"
}
# entry point
permission_check
printf "$W[$R*$W] Do you want to start the installer? y/n "
read START
if [[ $START == "y" || $START == "Y" ]]; then
printf "$W[$R*$W] Starting the installer ...\n"
sleep 1.25
elif [[ $START == "n" || $START == "N" ]]; then
printf "$W[$R*$W] All right, thank you for choosing the Hunter-Toolkit!\n"
exit 0
else
printf "$W[$R*$W] Invalid input, try again!\n"
exit 1
fi
printf "$W[$R*$W] installing the requirements ...\n"
install_requirements
printf "$W[$R*$W] create system command ...\n"
create_command
printf "$W[$G+$W] Hunter-Toolkit is now ready to use ...\n"
sleep 1.25
printf "$W[$R*$W] Do you want to start the Hunter-Toolkit? y/n "
read CHOICE
if [[ $CHOICE == "y" || $CHOICE == "Y" ]]; then
printf "$W[$R*$W] Starting the Hunter-Toolkit ...\n"
sleep 1.25
htkit
exit 0
elif [[ $CHOICE == "n" || $CHOICE == "N" ]]; then
printf "$W[$R*$W] All right, thank you for choosing the Hunter-Toolkit!\n"
exit 0
else
printf "$W[$Y-$W] Invalid Input!\n"
exit 1
fi