-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL.sh
executable file
·140 lines (140 loc) · 3.87 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Please provide the username under which the program will be installed"
exit 1
fi
priv_ok=false
if [[ $EUID -eq 1 ]]; then
priv_ok=true
else
sudo -k # make sure to ask for password on next sudo
if sudo true; then
priv_ok=true
else
priv_ok=false
fi
fi
if "$priv_ok"; then
# Password will not be asked again due to caching.
echo -n "Installing required toolset (this will take a few minutes)..."
if sudo apt -y install supervisor git python3-venv python3-pip libglib2.0-dev libgirepository1.0-dev libcairo2-dev > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Making installation directory..."
if sudo mkdir -p /etc/wpable > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Changing ownership of installation directory..."
if sudo chown $1 /etc/wpable > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Changing to installation directory..."
if cd /etc/wpable > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Getting installation files..."
if git clone https://github.com/samedayrules/wpable_server.git temp > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Copying files to final destination..."
if mv temp/* . > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Removing temporary files..."
if sudo rm -R temp > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Making python virtual environment..."
if python3 -m venv venv > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Activating virtual environment..."
if source venv/bin/activate > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Installing python packages (this will also take a few minutes)..."
if pip install -r requirements.txt > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Changing source files to target supplied username..."
if sed -i "s/linux/$1/g" service-auth.pkla wpable.conf > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Configuring supervisor to run program automatically..."
if sudo cp wpable.conf /etc/supervisor/conf.d/wpable.conf > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Creating wpa_supplicant template..."
if sudo cp wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Setting wpa_supplicant file permissions..."
if sudo chown $1 /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Creating program log file..."
if sudo touch /var/log/wpable.log > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Changing permission on program log file..."
if sudo chown $1 /var/log/wpable.log > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
echo -n "Allow program to re-start system services..."
if sudo cp /etc/wpable/service-auth.pkla /etc/polkit-1/localauthority/50-local.d > /dev/null 2>&1 ; then
echo "success"
else
echo "failed"
exit 1
fi
else
echo "Insufficient user privelege to continue"
fi