-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup-server.sh
executable file
·90 lines (78 loc) · 1.64 KB
/
setup-server.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
#!/bin/bash
export LC_ALL="C.UTF-8"
export LANG="C.UTF-8"
WHOAMI=$(whoami)
FAIL=false
if [ $WHOAMI != "root" ]
then
echo "[+] Setup running without permissions. System-wide changes cannot be made."
else
echo "[+] Setup running with permissions. Automatic installation will be attempted."
fi
if ! hash python3 >/dev/null
then
echo "[!] python3 not found"
if $WHOAMI == "root"
then
apt-get -y install python3.6
else
$FAIL=true
fi
else
echo "[+] python3 found"
fi
if ! hash pip3 >/dev/null
then
echo "[!] pip3 not found"
if $WHOAMI == "root"
then
apt-get -y install python3-pip
else
$FAIL=true
fi
else
echo "[+] pip3 found"
fi
if ! hash virtualenv >/dev/null
then
echo "[!] virtualenv not found"
if $WHOAMI == "root"
then
pip3 install virtualenv
else
$FAIL=true
fi
else
echo "[+] virtualenv found"
fi
if [ $FAIL = true ]
then
exit 1
fi
if [ ! -d venv ]
then
echo "[+] Creating new python3 virtualenv named venv"
virtualenv -p /usr/bin/python3 venv
fi
if [ ! -e venv/bin/activate ]
then
echo "[!] No venv activate script found"
exit 1
fi
if [ ! -e config/scope.txt ]
then
echo "[+] Generating default config/scope.txt"
echo "127.0.0.1" > config/scope.txt
fi
if [ ! -e config/blacklist.txt ]
then
echo "[+] Creating empty config/blacklist.txt"
echo "127.0.1.1" > config/blacklist.txt
fi
echo "[+] Entering virtual environment"
source venv/bin/activate
echo "[+] Attempting to install python dependencies"
pip3 install -r requirements.txt
echo "[+] Exiting virtual environment"
deactivate
echo "[+] Setup Complete"