-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.sh
executable file
·100 lines (81 loc) · 1.74 KB
/
install.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
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
100
#!/bin/bash
if [[ $(id -u) -ne 0 ]] ;
then echo "Please run as root ( sudo )" ; exit 1 ;
fi;
if ! which python3 > /dev/null 2>&1; then
echo Python 3 is not installed;
exit 1;
fi;
if ! which npm > /dev/null 2>&1; then
echo Nodejs is not installed;
exit 1;
fi;
echo - Creating virtual environment...;
python3 -m venv venv || exit 1;
source venv/bin/activate;
echo Done;
echo;
echo - Installing packages...;
pip install -U pip;
pip install -r requirements.txt || exit 1;
echo Done;
echo;
echo - Creating migrations...
./manage.py makemigrations || exit 1;
echo Done;
echo;
echo - Running tests...
if ./manage.py test --failfast; then
echo Done;
echo;
else
echo;
echo -e "\e[31mSome tests failed, please fix the problem and retry\e[0m";
exit 1;
fi
echo - Generating SECRET_KEY...;
cd install || exit 1;
python gen_sec_key.py;
echo Done;
echo;
echo - Exiting install directory;
cd ..;
echo;
echo - Migrate database and loading static files...;
./manage.py migrate || exit 1;
./manage.py collectstatic --noinput;
echo Done;
echo;
echo - Loading fixtures...;
./manage.py loaddata install/fixtures.json;
while true; do
read -rp "Load commands fixtures? ( pre-defined commands ) [y/n] : " fixtures;
if [ "$fixtures" == "y" ]; then
./manage.py loaddata install/linux_commands.json;
break;
elif [ "$fixtures" == "n" ]; then
break;
fi;
done;
echo Done;
echo;
while true; do
read -rp "Create superuser? [y/n] : " superuser;
if [ "$superuser" == "y" ]; then
break;
elif [ "$superuser" == "n" ]; then
break;
fi;
done
echo
if [ "$superuser" == "y" ]; then
echo - Creating superuser...;
./manage.py createsuperuser;
echo Done;
echo;
fi
echo - Cleaning up...;
rm -rf install/;
rm -f install.sh;
echo Done;
echo;