forked from EasySCP/EasySCP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
easyscp-setup.sh
343 lines (274 loc) · 8.34 KB
/
easyscp-setup.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
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
#!/bin/sh
# EasySCP a Virtual Hosting Control Panel
# Copyright (C) 2010-2018 by Easy Server Control Panel - http://www.easyscp.net
#
# This work is licensed under the Creative Commons Attribution-NoDerivs 3.0 Unported License.
# To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/.
#
# @link http://www.easyscp.net
# @author EasySCP Team
Auswahl=""
OS=""
clear
# Looks Better
echo '___________ ____________________________';
echo '\_ _____/____ _________.__./ _____/\_ ___ \______ \';
echo ' | __)_\__ \ / ___< | |\_____ \ / \ \/| ___/';
echo ' | \/ __ \_\___ \ \___ |/ \\ \___| | ';
echo '/_______ (____ /____ >/ ____/_______ / \______ /____| ';
echo ' \/ \/ \/ \/ \/ \/ ';
echo ""
echo "1 = CentOS"
echo ""
echo "2 = Debian"
echo ""
echo "3 = OpenSuse"
echo ""
echo "4 = Oracle Linux"
echo ""
echo "5 = Ubuntu"
echo ""
while :
do
read -p "Please select your distribution: " Name
if [ "$Name" = "1" ] || [ "$Name" = "CentOS" ]; then
Auswahl="CentOS"
fi
if [ "$Name" = "2" ] || [ "$Name" = "Debian" ]; then
Auswahl="Debian"
fi
if [ "$Name" = "3" ] || [ "$Name" = "OpenSuse" ]; then
Auswahl="OpenSuse"
fi
if [ "$Name" = "4" ] || [ "$Name" = "Oracle Linux" ]; then
Auswahl="Oracle"
fi
if [ "$Name" = "5" ] || [ "$Name" = "Ubuntu" ]; then
Auswahl="Ubuntu"
fi
case "$Auswahl" in
CentOS)
echo "Using CentOS. Please wait."
echo "Build the Software"
cd $(dirname $0)"/"
make -f Makefile.$Auswahl install > /dev/null
echo "Copy required files to your system"
cp -fLpR /tmp/easyscp/* / > /dev/null
if [ ! -f /etc/easyscp/EasySCP_Config.xml ]; then
cp /etc/easyscp/tpl/EasySCP_Config.xml /etc/easyscp/EasySCP_Config.xml
fi
while :
do
read -p "Secure your MySQL installation [Y/N]?" MySQL
case "$MySQL" in
[JjYy])
#echo "ja"
mysql_secure_installation
break
;;
[Nn])
#echo "nein"
break
;;
*)
echo "Wrong selection"
;;
esac
done
echo "Clean the temporary folders"
# rm -fR /tmp/easyscp/
echo "Prepare system config"
TIMEZONE=`timedatectl | gawk -F'[: ]+' ' $2 ~ /Time/ {print $4}'`
echo $TIMEZONE > /etc/timezone
TIMEZONE=$(cat /etc/timezone | sed "s/\//\\\\\//g")
sed -i".bak" "s/^\;date\.timezone.*$/date\.timezone = \"${TIMEZONE}\" /g" /etc/php.ini
# TIMEZONE=$((cat /etc/sysconfig/clock) | sed 's/^[^"]*"//' | sed 's/".*//')
# sed -i".bak" "s/^\;date\.timezone.*$/date\.timezone = \"${TIMEZONE}\" /g" /etc/php.ini
#touch /var/log/rkhunter.log
#chmod 644 /var/log/rkhunter.log
chmod 0700 -R /var/www/easyscp/daemon/
chmod 0777 /var/www/setup/theme/templates_c/
chmod 0777 /var/www/setup/config.xml
chcon --reference /etc/httpd/conf.d /etc/httpd/vhost.d
if [ ! -f /etc/httpd/conf.d/vhost.conf ]; then
echo "Include vhost.d/*.conf" >>/etc/httpd/conf.d/vhost.conf
fi
while :
do
read -p "Configure iptables [y/n]? (if unsure, select yes)" IPTables
case "$IPTables" in
[JjYy])
#echo "ja"
iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited
break
;;
[Nn])
#echo "nein"
break
;;
*)
echo "Wrong selection"
;;
esac
done
echo "Restarting Web Server"
/bin/systemctl restart httpd.service
echo "Starting EasySCP Controller"
/bin/systemctl start easyscp_control.service
echo "Starting EasySCP Daemon"
/bin/systemctl start easyscp_daemon.service
echo ""
echo "To finish Setup, please enter 'http://YOUR_DOMAIN/setup' into your Browser"
break
;;
Debian|Ubuntu)
echo "Using $Auswahl. Please wait."
echo "Build the Software"
cd $(dirname $0)"/"
make -f Makefile.$Auswahl install > /dev/null
echo "Copy required files to your system"
cp -pR /tmp/easyscp/* / > /dev/null
if [ ! -f /etc/easyscp/EasySCP_Config.xml ]; then
cp -p /etc/easyscp/tpl/EasySCP_Config.xml /etc/easyscp/EasySCP_Config.xml
fi
while :
do
read -p "Secure your MariaDB/MySQL installation [Y/N]?" MySQL
case "$MySQL" in
[JjYy])
#echo "ja"
mysql_secure_installation
break
;;
[Nn])
#echo "nein"
break
;;
*)
echo "Wrong selection"
;;
esac
done
echo "Clean the temporary folders"
rm -fR /tmp/easyscp/
echo "Prepare system config"
touch /var/log/rkhunter.log
chmod 644 /var/log/rkhunter.log
chmod 0700 -R /var/www/easyscp/daemon/
chmod 0777 /var/www/setup/theme/templates_c/
chmod 0777 /var/www/setup/config.xml
# Checking for bind9 and remove them if needed
echo "Checking for Bind9"
if [ -f /etc/init.d/bind9 ]; then
yes|apt-get remove bind9
fi
# Remove all old apache vhost/site configs
rm /etc/apache2/sites-enabled/* > /dev/null
# a2dissite default > /dev/null
a2ensite easyscp-setup.conf > /dev/null
/etc/init.d/apache2 restart
if [ -f /lib/systemd/system/easyscp_control.service ]; then
chmod 0644 /lib/systemd/system/easyscp_control.service
fi
echo "Starting EasySCP Controller"
/etc/init.d/easyscp_control start > /dev/null
if [ -f /lib/systemd/system/easyscp_daemon.service ]; then
chmod 0644 /lib/systemd/system/easyscp_daemon.service
fi
echo "Starting EasySCP Daemon"
/etc/init.d/easyscp_daemon start > /dev/null
echo ""
echo "To finish Setup, please enter 'http://YOUR_DOMAIN/setup' into your Browser"
break
;;
OpenSuse)
# echo "Using OpenSuse. Please wait."
echo "Easy Setup currently does not support OpenSuse."
# break
;;
Oracle)
echo "Using Oracle Linux. Please wait."
echo "Build the Software"
cd $(dirname $0)"/"
make -f Makefile.$Auswahl install > /dev/null
echo "Copy required files to your system"
cp -RLf /tmp/easyscp/* / > /dev/null
if [ ! -f /etc/easyscp/EasySCP_Config.xml ]; then
cp /etc/easyscp/tpl/EasySCP_Config.xml /etc/easyscp/EasySCP_Config.xml
fi
while :
do
read -p "Secure your mysql installation [Y/N]?" MySQL
case "$MySQL" in
[JjYy])
#echo "ja"
mysql_secure_installation
break
;;
[Nn])
#echo "nein"
break
;;
*)
echo "Wrong selection"
;;
esac
done
echo "Clean the temporary folders"
# rm -fR /tmp/easyscp/
echo "Prepare system config"
TIMEZONE=`cat /etc/sysconfig/clock | sed "s/^[^\"]*\"//" | sed "s/\".*//"`
echo $TIMEZONE > /etc/timezone
TIMEZONE=$(cat /etc/timezone | sed "s/\//\\\\\//g")
sed -i".bak" "s/^\;date\.timezone.*$/date\.timezone = \"${TIMEZONE}\" /g" /etc/php.ini
# TIMEZONE=$((cat /etc/sysconfig/clock) | sed 's/^[^"]*"//' | sed 's/".*//')
# sed -i".bak" "s/^\;date\.timezone.*$/date\.timezone = \"${TIMEZONE}\" /g" /etc/php.ini
#touch /var/log/rkhunter.log
#chmod 644 /var/log/rkhunter.log
chmod 0700 -R /var/www/easyscp/daemon/
chmod 0777 /var/www/setup/theme/templates_c/
chmod 0777 /var/www/setup/config.xml
chcon --reference /etc/httpd/conf.d /etc/httpd/vhost.d
if [ ! -f /etc/httpd/conf.d/vhost.conf ]; then
echo "Include vhost.d/*.conf" >>/etc/httpd/conf.d/vhost.conf
fi
chcon --reference /etc/httpd/conf.d/README /etc/httpd/conf.d/vhost.conf
while :
do
read -p "Configure iptables [Y/N]? (if unsure, select no)" IPTables
case "$IPTables" in
[JjYy])
#echo "ja"
iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited
break
;;
[Nn])
#echo "nein"
break
;;
*)
echo "Wrong selection"
;;
esac
done
service httpd restart
# /etc/init.d/httpd restart
echo "Starting EasySCP Controller"
/etc/init.d/easyscp_control start > /dev/null
echo "Starting EasySCP Daemon"
/etc/init.d/easyscp_daemon start > /dev/null
echo ""
echo "To finish Setup, please enter 'http://YOUR_DOMAIN/setup' into your Browser"
break
;;
*)
echo "Please type a number or the name of your distribution!"
#Wenn vorher nichts passte
;;
esac
done
exit 0