-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.sh
executable file
·533 lines (498 loc) · 18.5 KB
/
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
#!/bin/bash
APADIR='/etc/apache2'
OLSDIR='/usr/local/lsws'
CERTDIR='/etc/ssl'
USER=''
GROUP=''
PHP_P='8'
PHP_S='1'
REMOTE='False' #'True'
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
echoY() {
echo -e "\033[38;5;148m${1}\033[39m"
}
echoG() {
echo -e "\033[38;5;71m${1}\033[39m"
}
echoR()
{
echo -e "\033[38;5;203m${1}\033[39m"
}
change_owner(){
chown -R ${USER}:${GROUP} ${1}
}
silent() {
if [[ $debug ]] ; then
"$@"
else
"$@" >/dev/null 2>&1
fi
}
line_change(){
LINENUM=$(grep -v '#' ${2} | grep -n "${1}" | cut -d: -f 1)
if [ -n "$LINENUM" ] && [ "$LINENUM" -eq "$LINENUM" ] 2>/dev/null; then
sed -i "${LINENUM}d" ${2}
sed -i "${LINENUM}i${3}" ${2}
fi
}
gen_folder(){
mkdir -p /var/www/html
change_owner '/var/www/html'
}
backup_old(){
if [ -f ${1} ] && [ ! -f ${1}_old ]; then
mv ${1} ${1}_old
fi
}
rm_old_pkg(){
silent systemctl stop ${1}
if [ ${OSNAME} = 'centos' ]; then
silent yum remove ${1} -y
else
silent apt remove ${1} -y
fi
if [ "$(systemctl is-active ${1})" != 'active' ]; then
echoG "[OK] remove ${1}"
else
echoR "[Failed] remove ${1}"
fi
}
check_remote(){
if [ "${BACKEND_IP}" = '127.0.0.1' ]; then
REMOTE='False'
else
REMOTE='True'
echoG 'Detect remote server, will skip Apache setup!'
fi
}
checkweb(){
if [ ${1} = 'lsws' ] || [ ${1} = 'ols' ]; then
ps -ef | grep lshttpd | grep -v grep >/dev/null 2>&1
else
ps -ef | grep "${1}" | grep -v grep >/dev/null 2>&1
fi
if [ ${?} = 0 ]; then
echoG "${1} process is running!"
echoG 'Stop web service temporary'
if [ "${1}" = 'lsws' ]; then
PROC_NAME='lshttpd'
silent ${LSDIR}/bin/lswsctrl stop
ps aux | grep '[w]swatch.sh' >/dev/null 2>&1
if [ ${?} = 0 ]; then
kill -9 $(ps aux | grep '[w]swatch.sh' | awk '{print $2}')
fi
elif [ "${1}" = 'ols' ]; then
PROC_NAME='lshttpd'
silent ${OLSDIR}/bin/lswsctrl stop
elif [ "${1}" = 'httpd' ]; then
PROC_NAME='httpd'
silent systemctl stop ${PROC_NAME}
elif [ "${1}" = 'apache2' ]; then
PROC_NAME='apache2'
silent systemctl stop ${PROC_NAME}
fi
sleep 5
if [ $(systemctl is-active ${PROC_NAME}) != 'active' ]; then
echoG "[OK] Stop ${PROC_NAME} service"
else
echoR "[Failed] Stop ${PROC_NAME} service"
fi
else
echoR '[ERROR] Failed to start the web server.'
ps -ef | grep ${PROC_NAME} | grep -v grep
fi
}
check_os()
{
OSTYPE=$(uname -m)
MARIADBCPUARCH=
if [ -f /etc/redhat-release ] ; then
OSVER=$(cat /etc/redhat-release | awk '{print substr($4,1,1)}')
if [ ${?} = 0 ] ; then
OSNAMEVER=CENTOS${OSVER}
OSNAME=centos
rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el${OSVER}.noarch.rpm >/dev/null 2>&1
fi
elif [ -f /etc/lsb-release ] ; then
OSNAME=ubuntu
wget -qO - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash >/dev/null 2>&1
UBUNTU_V=$(grep 'DISTRIB_RELEASE' /etc/lsb-release | awk -F '=' '{print substr($2,1,2)}')
if [ ${UBUNTU_V} = 16 ] ; then
OSNAMEVER=UBUNTU16
OSVER=xenial
MARIADBCPUARCH="arch=amd64,i386,ppc64el"
elif [ ${UBUNTU_V} = 18 ] ; then
OSNAMEVER=UBUNTU18
OSVER=bionic
MARIADBCPUARCH="arch=amd64"
elif [ ${UBUNTU_V} = 20 ] ; then
OSNAMEVER=UBUNTU20
OSVER=focal
MARIADBCPUARCH="arch=amd64"
elif [ ${UBUNTU_V} = 22 ] ; then
OSNAMEVER=UBUNTU22
OSVER=jammy
MARIADBCPUARCH="arch=amd64"
fi
elif [ -f /etc/debian_version ] ; then
OSNAME=debian
wget -qO - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash >/dev/null 2>&1
DEBIAN_V=$(awk -F '.' '{print $1}' /etc/debian_version)
if [ ${DEBIAN_V} = 7 ] ; then
OSNAMEVER=DEBIAN7
OSVER=wheezy
MARIADBCPUARCH="arch=amd64,i386"
elif [ ${DEBIAN_V} = 8 ] ; then
OSNAMEVER=DEBIAN8
OSVER=jessie
MARIADBCPUARCH="arch=amd64,i386"
elif [ ${DEBIAN_V} = 9 ] ; then
OSNAMEVER=DEBIAN9
OSVER=stretch
MARIADBCPUARCH="arch=amd64,i386"
elif [ ${DEBIAN_V} = 10 ] ; then
OSNAMEVER=DEBIAN10
OSVER=buster
elif [ ${DEBIAN_V} = 11 ] ; then
OSNAMEVER=DEBIAN11
OSVER=bullseye
fi
fi
if [ "${OSNAMEVER}" = "" ] ; then
echoR "Sorry, currently script only supports Centos(7-8), Debian(7-11) and Ubuntu(16,18,20,22)."
exit 1
else
if [ "${OSNAME}" = "centos" ] ; then
echoG "Current platform is ${OSNAME} ${OSVER}"
else
export DEBIAN_FRONTEND=noninteractive
echoG "Current platform is ${OSNAMEVER} ${OSNAME} ${OSVER}."
fi
fi
}
path_update(){
if [ "${OSNAME}" = "centos" ] ; then
USER='apache'
GROUP='apache'
REPOPATH='/etc/yum.repos.d'
APACHENAME='httpd'
APADIR='/etc/httpd'
RED_VER=$(rpm -q --whatprovides redhat-release)
elif [ "${OSNAME}" = 'ubuntu' ] || [ "${OSNAME}" = 'debian' ]; then
USER='www-data'
GROUP='www-data'
REPOPATH='/etc/apt/sources.list.d'
APACHENAME='apache2'
FPMCONF="/etc/php/${PHP_P}.${PHP_S}/fpm/pool.d/www.conf"
fi
}
ubuntu_sysupdate(){
echoG 'System update'
silent apt-get update
silent DEBIAN_FRONTEND=noninteractive apt-get -y \
-o Dpkg::Options::='--force-confdef' \
-o Dpkg::Options::='--force-confold' upgrade
silent DEBIAN_FRONTEND=noninteractive apt-get -y \
-o Dpkg::Options::='--force-confdef' \
-o Dpkg::Options::='--force-confold' dist-upgrade
}
centos_sysupdate(){
echoG 'System update'
silent yum update -y
setenforce 0
}
gen_selfsigned_cert(){
KEYNAME="${CERTDIR}/example.key"
CERTNAME="${CERTDIR}/example.crt"
openssl ecparam -genkey -name prime256v1 -out ${KEYNAME}
silent openssl req -x509 -nodes -days 365 -new -key ${KEYNAME} -out ${CERTNAME} <<csrconf
US
NJ
Virtual
Example
Testing
webadmin
.
.
.
csrconf
}
ubuntu_pkg_basic(){
echoG 'Install basic packages'
if [ ! -e /bin/wget ]; then
silent apt-get install lsb-release -y
silent apt-get install curl wget -y
fi
silent apt-get install curl net-tools software-properties-common -y
}
centos_pkg_basic(){
echoG 'Install basic packages'
if [ ! -e /bin/wget ]; then
silent yum install epel-release -y
silent yum update -y
silent yum install curl yum-utils wget -y
fi
if [[ -z "$(rpm -qa epel-release)" ]]; then
silent yum install epel-release -y
fi
if [ ! -e /usr/bin/yum-config-manager ]; then
silent yum install yum-utils -y
fi
if [ ! -e /usr/bin/curl ]; then
silent yum install curl -y
fi
}
ubuntu_install_apache(){
echoG 'Install Apache Web Server'
if [ -e /usr/sbin/${APACHENAME} ]; then
echoY "Remove existing ${APACHENAME}"
rm_old_pkg ${APACHENAME}
fi
yes "" | add-apt-repository ppa:ondrej/apache2 >/dev/null 2>&1
if [ "$(grep -iR apache2 ${REPOPATH}/)" = '' ]; then
echoR '[Failed] to add APACHE2 repository'
fi
silent apt-get update
apt install ${APACHENAME} -y >/dev/null 2>&1
if [ "${REMOTE}" = 'False' ]; then
systemctl start ${APACHENAME} >/dev/null 2>&1
SERVERV=$(echo $(apache2 -v | grep version) | awk '{print substr ($3,8,9)}')
checkweb ${APACHENAME}
echoG "Version: apache ${SERVERV}"
else
echoG 'Skip apache service start!'
fi
}
centos_install_apache(){
echoG 'Install Apache Web Server'
if [ -e /usr/sbin/${APACHENAME} ]; then
echoY "Remove existing ${APACHENAME}"
rm_old_pkg ${APACHENAME}
silent yum remove httpd* -y
KILL_PROCESS ${APACHENAME}
fi
cd ${REPOPATH}
if [ "${OSNAMEVER}" != "CENTOS8" ] ; then
wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo >/dev/null 2>&1
fi
silent yum install ${APACHENAME} mod_ssl -y
sleep 1
if [ "${REMOTE}" = 'False' ]; then
silent systemctl start ${APACHENAME}
SERVERV=$(echo $(httpd -v | grep version) | awk '{print substr ($3,8,9)}')
checkweb ${APACHENAME}
echoG "Version: apache ${SERVERV}"
else
echoG 'Skip apache service start!'
fi
}
ubuntu_install_ols(){
echoG 'Install openLiteSpeed Web Server'
ubuntu_reinstall 'openlitespeed'
wget -q -O - http://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh | bash >/dev/null 2>&1
/usr/bin/apt ${OPTIONAL} install openlitespeed -y >/dev/null 2>&1
ENCRYPT_PASS=$(${OLSDIR}/admin/fcgi-bin/admin_php* -q ${OLSDIR}/admin/misc/htpasswd.php ${ADMIN_PASS})
echo "admin:${ENCRYPT_PASS}" > ${OLSDIR}/admin/conf/htpasswd
SERVERV=$(cat ${OLSDIR}/VERSION)
echoG "Version: openlitespeed ${SERVERV}"
checkweb ols
}
centos_install_ols(){
echoG 'Install openLiteSpeed Web Server'
centos_reinstall 'openlitespeed'
if [ ${OSVER} = 8 ]; then
silent rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm
elif [ ${OSVER} = 7 ]; then
silent rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm
fi
silent /usr/bin/yum ${OPTIONAL} openlitespeed -y
ENCRYPT_PASS=$(${OLSDIR}/admin/fcgi-bin/admin_php* -q ${OLSDIR}/admin/misc/htpasswd.php ${ADMIN_PASS})
echo "admin:${ENCRYPT_PASS}" > ${OLSDIR}/admin/conf/htpasswd
SERVERV=$(cat ${OLSDIR}/VERSION)
echoG "Version: openlitespeed ${SERVERV}"
echo "Version: openlitespeed ${SERVERV}" >> ${SERVERACCESS}
checkweb ols
}
ubuntu_reinstall(){
apt --installed list 2>/dev/null | grep ${1} >/dev/null
if [ ${?} = 0 ]; then
OPTIONAL='--reinstall'
else
OPTIONAL=''
fi
}
centos_reinstall(){
rpm -qa | grep ${1} >/dev/null
if [ ${?} = 0 ]; then
OPTIONAL='reinstall'
else
OPTIONAL='install'
fi
}
ubuntu_install_php(){
echoG 'Install PHP & Packages for LSWS'
ubuntu_reinstall "lsphp${PHP_P}${PHP_S}"
wget -qO - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash >/dev/null 2>&1
for PKG in '' -common -curl -json -modules-source -mysql -opcache -pspell -recode -sybase -tidy; do
/usr/bin/apt ${OPTIONAL} install -y lsphp${PHP_P}${PHP_S}${PKG} >/dev/null 2>&1
done
echoG 'Install PHP & Packages for Apache'
if [ "${REMOTE}" = 'False' ]; then
ubuntu_reinstall "php${PHP_P}.${PHP_S}"
for PKG in '' -bcmath -cli -common -curl -enchant -fpm -gd -gmp -json -mbstring -mysql -opcache \
-pspell -readline -recode -soap -tidy -xml -xmlrpc -zip; do
/usr/bin/apt ${OPTIONAL} install -y php${PHP_P}.${PHP_S}${PKG} >/dev/null 2>&1
done
sed -i -e 's/extension=pdo_dblib.so/;extension=pdo_dblib.so/' \
/usr/local/lsws/lsphp${PHP_P}${PHP_S}/etc/php/${PHP_P}.${PHP_S}/mods-available/pdo_dblib.ini
sed -i -e 's/extension=shmop.so/;extension=shmop.so/' /etc/php/${PHP_P}.${PHP_S}/fpm/conf.d/20-shmop.ini
if [ ${OSNAMEVER} != 'UBUNTU20' ]; then
sed -i -e 's/extension=wddx.so/;extension=wddx.so/' /etc/php/${PHP_P}.${PHP_S}/fpm/conf.d/20-wddx.ini
fi
NEWKEY='listen.backlog = 4096'
line_change 'listen.backlog' ${FPMCONF} "${NEWKEY}"
else
echoG 'Skip!'
fi
}
centos_install_php(){
echoG 'Install PHP & Packages'
/usr/bin/yum install -y http://rpms.remirepo.net/enterprise/remi-release-${OSVER}.rpm >/dev/null 2>&1
/usr/bin/yum install -y yum-utils >/dev/null 2>&1
/usr/bin/yum-config-manager --enable remi-php${PHP_P}${PHP_S} >/dev/null 2>&1
for PKG in '' -common -pdo -gd -mbstring -mysqlnd -litespeed -opcache -pecl-zip -tidy -gmp -bcmath \
-enchant -cli -json -xml -fpm -recode -soap -xmlrpc -sodium; do
/usr/bin/yum install php${PKG} -y >/dev/null 2>&1
done
sed -i -e 's/extension=bz2/;extension=bz2/' /etc/php.d/20-bz2.ini
sed -i -e 's/extension=pdo_sqlite/;extension=pdo_sqlite/' /etc/php.d/30-pdo_sqlite.ini
sed -i -e 's/extension=sqlite3/;extension=sqlite3/' /etc/php.d/20-sqlite3.ini
sed -i -e 's/extension=wddx/;extension=wddx/' /etc/php.d/30-wddx.ini
mkdir -p /var/run/php/
NEWKEY="listen = /var/run/php/php${PHP_P}.${PHP_S}-fpm.sock"
line_change 'listen = ' ${FPMCONF} "${NEWKEY}"
NEWKEY="listen.owner = ${USER}"
line_change 'listen.owner = ' ${FPMCONF} "${NEWKEY}"
NEWKEY="listen.group = ${GROUP}"
line_change 'listen.group = ' ${FPMCONF} "${NEWKEY}"
NEWKEY='listen.mode = 0660'
line_change 'listen.mode = ' ${FPMCONF} "${NEWKEY}"
NEWKEY='listen.backlog = 4096'
line_change 'listen.backlog' ${FPMCONF} "${NEWKEY}"
}
ubuntu_setup_apache(){
echoG 'Setting Apache Config'
if [ "${REMOTE}" = 'False' ]; then
cd ${SCRIPTPATH}/
a2enmod proxy_fcgi >/dev/null 2>&1
a2enconf php${PHP_P}.${PHP_S}-fpm >/dev/null 2>&1
a2enmod mpm_event >/dev/null 2>&1
a2enmod ssl >/dev/null 2>&1
a2enmod http2 >/dev/null 2>&1
a2disconf other-vhosts-access-log >/dev/null 2>&1
cp webservers/apache/conf/deflate.conf ${APADIR}/mods-available
cp webservers/apache/conf/default-ssl.conf ${APADIR}/sites-available
if [ ! -e ${APADIR}/sites-enabled/000-default-ssl.conf ]; then
ln -s ${APADIR}/sites-available/default-ssl.conf ${APADIR}/sites-enabled/000-default-ssl.conf
fi
if [ ! -e ${APADIR}/conf-enabled/php${PHP_P}.${PHP_S}-fpm.conf ]; then
ln -s ${APADIR}/conf-available/php${PHP_P}.${PHP_S}-fpm.conf ${APADIR}/conf-enabled/php${PHP_P}.${PHP_S}-fpm.conf
fi
sed -i "s/80/${BACKEND_HTTP_PORT}/g" ${APADIR}/sites-available/000-default.conf
sed -i "s/80/${BACKEND_HTTP_PORT}/g" ${APADIR}/sites-enabled/000-default.conf
sed -i "s/80/${BACKEND_HTTP_PORT}/g" ${APADIR}/ports.conf
sed -i "s/443/${BACKEND_HTTPS_PORT}/g" ${APADIR}/sites-available/default-ssl.conf
sed -i "s/443/${BACKEND_HTTPS_PORT}/g" ${APADIR}/ports.conf
sed -i '/ CustomLog/s/^/#/' ${APADIR}/sites-enabled/000-default.conf
systemctl restart apache2
else
echoG 'Skip!'
fi
}
centos_setup_apache(){
echoG 'Setting Apache Config'
if [ "${REMOTE}" = 'False' ]; then
cd ${SCRIPTPATH}/
echo "Protocols h2 http/1.1" >> /etc/httpd/conf/httpd.conf
sed -i '/logs\/access_log" common/s/^/#/' /etc/httpd/conf/httpd.conf
sed -i '/LoadModule mpm_prefork_module/s/^/#/g' /etc/httpd/conf.modules.d/00-mpm.conf
sed -i '/LoadModule mpm_event_module/s/^#//g' /etc/httpd/conf.modules.d/00-mpm.conf
sed -i "s+SetHandler application/x-httpd-php+SetHandler proxy:unix:/var/run/php/php${PHP_P}.${PHP_S}-fpm.sock|fcgi://localhost+g" \
/etc/httpd/conf.d/php.conf
cp webservers/apache/conf/deflate.conf ${APADIR}/conf.d
cp webservers/apache/conf/default-ssl.conf ${APADIR}/conf.d
sed -i '/ErrorLog/s/^/#/g' /etc/httpd/conf.d/default-ssl.conf
sed -i "s/80/${BACKEND_HTTP_PORT}/g" ${APADIR}/conf/httpd.conf
sed -i "s/443/${BACKEND_HTTPS_PORT}/g" ${APADIR}/conf.d/default-ssl.conf
systemctl restart httpd
else
echoG 'Skip!'
fi
}
ubuntu_setup_ols(){
echoG 'Setting OpenLiteSpeed Config'
cd ${SCRIPTPATH}/
backup_old ${OLSDIR}/conf/httpd_config.conf
backup_old ${OLSDIR}/Example/conf/vhconf.conf
cp ./webservers/openlitespeed/conf/httpd_config.conf ${OLSDIR}/conf/
cp ./webservers/openlitespeed/conf/vhconf.conf ${OLSDIR}/conf/vhosts/Example/
sed -i "s/\:80/\:${BACKEND_HTTP_PORT}/g" ${OLSDIR}/conf/vhosts/Example/vhconf.conf
sed -i "s/\:443/\:${BACKEND_HTTPS_PORT}/g" ${OLSDIR}/conf/vhosts/Example/vhconf.conf
sed -i "s/127.0.0.1/${BACKEND_IP}/g" ${OLSDIR}/conf/vhosts/Example/vhconf.conf
sed -i "s/www.example.com/${BACKEND_DOMAIN}/g" ${OLSDIR}/conf/vhosts/Example/vhconf.conf
change_owner ${OLSDIR}/cachedata
rm -f /tmp/lshttpd/.rtreport
service lsws restart
}
centos_setup_ols(){
echoG 'Setting OpenLiteSpeed Config'
cd ${SCRIPTPATH}/
backup_old ${OLSDIR}/conf/httpd_config.conf
backup_old ${OLSDIR}/Example/conf/vhconf.conf
cp ./webservers/openlitespeed/conf/httpd_config.conf ${OLSDIR}/conf/
cp ./webservers/openlitespeed/conf/vhconf.conf ${OLSDIR}/conf/vhosts/Example/
sed -i "s/www-data/${USER}/g" ${OLSDIR}/conf/httpd_config.conf
sed -i "s|/usr/local/lsws/lsphp${PHP_P}${PHP_S}/bin/lsphp|/usr/bin/lsphp|g" ${OLSDIR}/conf/httpd_config.conf
sed -i "s/:80/:${BACKEND_HTTP_PORT}/g" ${OLSDIR}/conf/vhosts/Example/vhconf.conf
sed -i "s/:443/:${BACKEND_HTTPS_PORT}/g" ${OLSDIR}/conf/vhosts/Example/vhconf.conf
sed -i "s/127.0.0.1/${BACKEND_IP}/g" ${OLSDIR}/conf/vhosts/Example/vhconf.conf
sed -i "s/www.example.com/${BACKEND_DOMAIN}/g" ${OLSDIR}/conf/vhosts/Example/vhconf.conf
change_owner ${OLSDIR}/cachedata
rm -f /tmp/lshttpd/.rtreport
service lsws restart
}
prepare(){
check_os
path_update
check_remote
gen_folder
gen_selfsigned_cert
}
testcase(){
curl -Iks --http1.1 http://${BACKEND_IP}:80/ | grep -i LiteSpeed && echoG 'Good' || echoR 'Please check'
curl -Iks --http1.1 https://${BACKEND_IP}:443/ | grep -i LiteSpeed && echoG 'Good' || echoR 'Please check'
if [ "${REMOTE}" = 'False' ]; then
curl -Iks --http1.1 http://${BACKEND_IP}:${BACKEND_HTTP_PORT}/ | grep -i Apache && echoG 'Good' || echoR 'Please check'
curl -Iks --http1.1 https://${BACKEND_IP}:${BACKEND_HTTPS_PORT}/ | grep -i Apache && echoG 'Good' || echoR 'Please check'
fi
}
main(){
prepare
if [ ${OSNAME} = 'centos' ]; then
centos_pkg_basic
centos_install_apache
centos_install_ols
centos_install_php
centos_setup_apache
centos_setup_ols
else
ubuntu_pkg_basic
ubuntu_install_apache
ubuntu_install_ols
ubuntu_install_php
ubuntu_setup_apache
ubuntu_setup_ols
fi
testcase
}
source backend-cnf && main