-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·280 lines (245 loc) · 5.24 KB
/
start.sh
File metadata and controls
executable file
·280 lines (245 loc) · 5.24 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#!/bin/bash
# path to sh
ABSOLUTE_FILENAME=$(readlink -e "$0")
# sh directory
DIRECTORY=$(dirname "$ABSOLUTE_FILENAME")
# sh files
chmod 500 "$DIRECTORY/parts" -R
# update packages
echo "updating packets..."
apt-get update
echo "done update"
echo
echo "upgrading packets..."
apt-get upgrade -y
echo "done upgrade"
apt-get install whiptail -y
whiptail \
--title "About" \
--msgbox "Welcome to cod2install.\\nVisit https://github.com/lonsofore/cod2install to get more information.\\nChoose Ok to continue." 10 60
option=$(whiptail \
--title "Install mode" \
--menu "Choose your option" 10 60 3 \
"1" "Minimal (only CoD2)" \
"2" "Full (CoD2 + Web Server)" \
"3" "Custom" \
3>&1 1>&2 2>&3) || { echo "You chose cancel."; exit 1; }
inst_lib=0
inst_serv=0
inst_user=0
inst_web=0
inst_mysql=0
inst_pma=0
inst_noip=0
inst_zram=0
case $option in
1)
inst_lib=1
inst_serv=1
inst_user=1
inst_noip=-1
inst_zram=-1
;;
2)
inst_lib=1
inst_serv=1
inst_user=1
inst_web=1
inst_mysql=1
inst_pma=1
inst_noip=-1
inst_zram=-1
;;
3)
whiptail \
--title "Custom installation" --checklist \
"Choose, what do you want to install:" 15 60 8 \
"cod2-libraries" "All libraries for CoD2" ON \
"cod2-servers" "Setup your CoD2 servers" ON \
"new-user" "Create new user (for cod2)" ON \
"web-server" "Web server" OFF \
"mysql-server" "MySQL server" OFF \
"phpmyadmin" "MySQL administration" OFF \
"noip-client" "Dyn dns (for gametracker.com)" OFF \
"zram" "Read about it on the internet!" OFF \
2>settings --separate-output || { echo "You chose cancel."; exit 1; }
while read -r choice
do
case $choice in
cod2-libraries) inst_lib=1
;;
cod2-servers) inst_serv=1
;;
new-user) inst_user=1
;;
web-server) inst_web=1
;;
mysql-server) inst_mysql=1
;;
phpmyadmin) inst_pma=1
;;
noip-client) inst_noip=1
;;
zram) inst_zram=1
;;
esac
done < settings
;;
esac
# settings: web server
if [ $inst_web -eq 1 ]
then
inst_web_serv=$(whiptail \
--title "Web server" \
--menu "Choose your web server" 10 60 2 \
"1" "lighttpd" \
"2" "apache2" \
3>&1 1>&2 2>&3)
fi
# settings: no ip client
if [ $inst_noip -eq -1 ]
then
if (whiptail --title "No-ip client" --yesno "Install no-ip client? Use can use it for gametracker.com (dynamic dns). It will require your noip account data, register on noip.com first!" 10 60 --defaultno)
then
inst_noip=1
else
inst_noip=0
fi
fi
# settings: compressor
if [ $inst_zram -eq -1 ]
then
if (whiptail --title "Compressor" --yesno "Install zRam? Read about it before!" 10 60 --defaultno)
then
inst_zram=1
else
inst_zram=0
fi
fi
# tools
echo
echo "installing tools..."
for pack in git ssh scp nano make screen zip unzip perl aria2 geoip-bin man-db sqlite sshpass;
do apt-get -y install $pack; done
echo "done tools"
# zram
if [ $inst_zram -eq 1 ]
then
apt-get -y install zram-config
fi
# cod2 requirements
if [ $inst_lib -eq 1 ]
then
"$DIRECTORY/parts/req.sh"
fi
# noip
if [ $inst_noip -eq 1 ]
then
"$DIRECTORY/parts/noip.sh"
fi
# web server
if [ $inst_web -eq 1 ]
then
# mysql-server
if [ $inst_mysql -eq 1 ]
then
echo
echo "installing mysql-server..."
apt-get install mysql-server -y
echo "done mysql-server"
fi
# web server: lighttpd or apache2
if [ "$inst_web_serv" -eq 1 ]
then
echo
echo "installing lighttpd..."
apt-get install lighttpd -y
echo "done lighttpd"
lighty-enable-mod cgi
lighty-enable-mod fastcgi
lighty-enable-mod fastcgi-php
else
echo
echo "installing apache2..."
apt-get install apache2 -y
echo "done apache2"
fi
# phpmyadmin
if [ $inst_pma -eq 1 ]
then
# to prevent installing apache2
os_ver=$(lsb_release -r -s)
if [ "$os_ver" == "14.04" ]
then
# we should install php5-cgi before
echo
echo "installing php5-cgi..."
apt-get install php5-cgi -y
echo "done php5-cgi"
# php5-fpm also
echo
echo "installing php5-fpm..."
apt-get install php5-fpm -y
echo "done php5-fpm"
else
# we should install php-cgi before
echo
echo "installing php-cgi..."
apt-get install php-cgi -y
echo "done php-cgi"
# php-fpm also
echo
echo "installing php-fpm..."
apt-get install php-fpm -y
echo "done php-fpm"
fi
# phpmyadmin
echo
echo "installing phpmyadmin..."
apt-get -y install phpmyadmin
echo "done phpmyadmin"
# link it
ln -s /usr/share/phpmyadmin/ /var/www/
fi
# restart
if [ "$inst_web_serv" -eq 1 ]
then
service lighttpd restart
else
service apache2 restart
fi
fi
# create new user
if [ $inst_user -eq 1 ]
then
user=$(whiptail \
--title "Create new user" \
--inputbox "Enter the name of new user" 10 60 \
3>&1 1>&2 2>&3)
echo
useradd "$user" -m -s /bin/bash
echo "created user $user"
passwd "$user"
echo
# copy files to new user
cp ~/cod2install "/home/$user/cod2install" -R
chown "$user:$user" "/home/$user" -R
chmod 700 "/home/$user/cod2install" -R
# log in new user and and set up servers
if [ $inst_serv -eq 1 ]
then
sudo -H -u $user sh -c "/home/$user/cod2install/parts/cod2.sh"
fi
else
# set up servers
if [ $inst_serv -eq 1 ]
then
~/cod2install/parts/cod2.sh
fi
fi
# final reboot
echo "That's all"
if (whiptail --title "Reboot" --yesno "Reboot the machine?" 10 60)
then
reboot
fi