forked from litespeedtech/ls-cloud-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpimgsetup.sh
1536 lines (1238 loc) · 35.1 KB
/
wpimgsetup.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
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# /********************************************************************
# LiteSpeed WordPress setup Script
# @Author: LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
# @Copyright: (c) 2019-2023
# *********************************************************************/
LSWSFD='/usr/local/lsws'
DOCHM='/var/www/html.old'
DOCLAND='/var/www/html'
PHPCONF='/var/www/phpmyadmin'
LSWSCONF="${LSWSFD}/conf/httpd_config.conf"
WPVHCONF="${LSWSFD}/conf/vhosts/wordpress/vhconf.conf"
EXAMPLECONF="${LSWSFD}/conf/vhosts/wordpress/vhconf.conf"
MEMCACHECONF='/etc/memcached.conf'
REDISSERVICE='/lib/systemd/system/redis-server.service'
REDISCONF='/etc/redis/redis.conf'
WPCONSTCONF="${DOCHM}/wp-content/plugins/litespeed-cache/data/const.default.ini"
MARIADBSERVICE='/lib/systemd/system/mariadb.service'
#MARIADBCNF='/etc/mysql/mariadb.conf.d/60-server.cnf'
PHPVER=74
FIREWALLLIST="22 80 443"
USER='www-data'
GROUP='www-data'
THEME='twentytwenty'
PLUGINLIST="litespeed-cache.zip all-in-one-wp-migration.zip google-analytics-for-wordpress.zip jetpack.zip dologin.zip"
root_mysql_pass=$(openssl rand -hex 24)
ALLERRORS=0
EXISTSQLPASS=''
NOWPATH=$(pwd)
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"
}
linechange(){
LINENUM=$(grep -n "${1}" ${2} | 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
}
cked()
{
if [ -f /bin/ed ]; then
echoG "ed exist"
else
echoG "no ed, ready to install"
if [ "${OSNAME}" = 'ubuntu' ] || [ "${OSNAME}" = 'debian' ]; then
apt-get install ed -y > /dev/null 2>&1
elif [ "${OSNAME}" = 'centos' ]; then
yum install ed -y > /dev/null 2>&1
fi
fi
}
get_sql_ver(){
SQLDBVER=$(/usr/bin/mysql -V | awk '{match($0,"([^ ]+)-MariaDB",a)}END{print a[1]}')
SQL_MAINV=$(echo ${SQLDBVER} | awk -F '.' '{print $1}')
SQL_SECV=$(echo ${SQLDBVER} | awk -F '.' '{print $2}')
}
check_sql_ver(){
if (( ${SQL_MAINV} >=11 && ${SQL_MAINV}<=99 )); then
echoG '[OK] Mariadb version -ge 11'
elif (( ${SQL_MAINV} >=10 )) && (( ${SQL_SECV} >=3 )); then
echoG '[OK] Mariadb version -ge 10.3'
else
echoR "Mariadb version ${SQLDBVER} is lower than 10.3, please check!"
fi
}
check_os()
{
if [ -f /etc/redhat-release ] ; then
OSNAME=centos
USER='nobody'
GROUP='nobody'
#MARIADBCNF='/etc/my.cnf.d/60-server.cnf'
REDISSERVICE='/lib/systemd/system/redis.service'
REDISCONF='/etc/redis.conf'
MEMCACHESERVICE='/etc/systemd/system/memcached.service'
MEMCACHECONF='/etc/sysconfig/memcached'
OSVER=$(cat /etc/redhat-release | awk '{print substr($4,1,1)}')
elif [ -f /etc/lsb-release ] ; then
OSNAME=ubuntu
OSNAMEVER="UBUNTU$(lsb_release -sr | awk -F '.' '{print $1}')"
elif [ -f /etc/debian_version ] ; then
OSNAME=debian
fi
}
providerck()
{
if [ ${OSNAME} = 'centos' ] && [ ! -e /usr/sbin/dmidecode ]; then
yum install -y dmidecode > /dev/null 2>&1
fi
if [ -e /sys/devices/virtual/dmi/id/product_uuid ] && [[ "$(sudo cat /sys/devices/virtual/dmi/id/product_uuid | cut -c 1-3)" =~ (EC2|ec2) ]]; then
PROVIDER='aws'
elif [ "$(dmidecode -s bios-vendor)" = 'Google' ];then
PROVIDER='google'
elif [ "$(dmidecode -s bios-vendor)" = 'DigitalOcean' ];then
PROVIDER='do'
elif [ "$(dmidecode -s bios-vendor)" = 'Vultr' ];then
PROVIDER='vultr'
elif [ "$(dmidecode -s system-product-name | cut -c 1-7)" = 'Alibaba' ];then
PROVIDER='aliyun'
elif [ "$(dmidecode -s system-manufacturer)" = 'Microsoft Corporation' ];then
PROVIDER='azure'
elif [ -e /etc/oracle-cloud-agent/ ]; then
PROVIDER='oracle'
else
PROVIDER='undefined'
fi
}
oshmpath()
{
if [ ${PROVIDER} = 'aws' ] && [ -d /home/ubuntu ]; then
HMPATH='/home/ubuntu'
elif [ ${PROVIDER} = 'google' ] && [ -d /home/ubuntu ]; then
HMPATH='/home/ubuntu'
elif [ ${PROVIDER} = 'aliyun' ] && [ -d /home/ubuntu ]; then
HMPATH='/home/ubuntu'
elif [ ${PROVIDER} = 'oracle' ] && [ -d /home/ubuntu ]; then
HMPATH='/home/ubuntu'
else
HMPATH='/root'
fi
DBPASSPATH="${HMPATH}/.db_password"
}
change_owner(){
chown -R ${USER}:${GROUP} ${1}
}
prepare(){
mkdir -p "${DOCLAND}"
change_owner /var/www
}
system_upgrade() {
echoG 'Updating system'
if [ "${OSNAME}" = 'ubuntu' ] || [ "${OSNAME}" = 'debian' ]; then
apt-get update > /dev/null 2>&1
echo -ne '##### (33%)\r'
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' upgrade > /dev/null 2>&1
echo -ne '############# (66%)\r'
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' dist-upgrade > /dev/null 2>&1
echo -ne '#################### (99%)\r'
apt-get clean > /dev/null 2>&1
apt-get autoclean > /dev/null 2>&1
echo -ne '####################### (100%)\r'
else
echo -ne '# (5%)\r'
yum update -y > /dev/null 2>&1
echo -ne '####################### (100%)\r'
fi
}
wp_conf_path(){
if [ -f "${LSWSCONF}" ]; then
if [ ! -f $(grep 'configFile.*wordpress' "${LSWSCONF}" | awk '{print $2}') ]; then
WPVHCONF="${EXAMPLECONF}"
fi
else
echo 'Can not find LSWS Config, exit script'
exit 1
fi
}
rm_dummy(){
echoG 'Remove dummy file'
rm -f "/tmp/example.csr" "/tmp/privkey.pem"
}
install_ols_wp(){
cd /tmp/; wget -q https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh
chmod +x ols1clk.sh
echo 'Y' | bash ols1clk.sh \
--lsphp ${PHPVER} \
--wordpress \
--wordpresspath ${DOCHM} \
--dbrootpassword ${root_mysql_pass} \
--dbname wordpress \
--dbuser wordpress \
--dbpassword wordpress
rm -f ols1clk.sh
wp_conf_path
rm_dummy
}
restart_lsws(){
echoG 'Restart LiteSpeed Web Server'
${LSWSFD}/bin/lswsctrl stop >/dev/null 2>&1
systemctl stop lsws >/dev/null 2>&1
systemctl start lsws >/dev/null 2>&1
}
centos_install_basic(){
yum -y install wget unzip > /dev/null 2>&1
}
centos_install_ols(){
install_ols_wp
}
centos_install_memcached(){
echoG 'Install Memcached'
yum -y install memcached > /dev/null 2>&1
systemctl start memcached > /dev/null 2>&1
systemctl enable memcached > /dev/null 2>&1
}
centos_install_redis(){
echoG 'Install Redis'
yum -y install redis > /dev/null 2>&1
systemctl start redis > /dev/null 2>&1
}
centos_install_certbot(){
echoG "Install CertBot"
if [ ${OSVER} = 8 ]; then
wget -q https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot
chown root /usr/local/bin/certbot
chmod 0755 /usr/local/bin/certbot
echo "y" | /usr/local/bin/certbot > /dev/null 2>&1
else
yum -y install certbot > /dev/null 2>&1
fi
if [ -e /usr/bin/certbot ] || [ -e /usr/local/bin/certbot ]; then
if [ ! -e /usr/bin/certbot ]; then
ln -s /usr/local/bin/certbot /usr/bin/certbot
fi
echoG 'Install CertBot finished'
else
echoR 'Please check CertBot'
fi
}
ubuntu_install_basic(){
apt-get -y install wget unzip > /dev/null 2>&1
}
ubuntu_install_ols(){
install_ols_wp
}
ubuntu_install_memcached(){
echoG 'Install Memcached'
apt-get -y install memcached > /dev/null 2>&1
systemctl start memcached > /dev/null 2>&1
systemctl enable memcached > /dev/null 2>&1
}
ubuntu_install_redis(){
echoG 'Install Redis'
apt-get -y install redis > /dev/null 2>&1
systemctl start redis > /dev/null 2>&1
}
ubuntu_install_certbot(){
echoG "Install CertBot"
if [ "${OSNAMEVER}" = 'UBUNTU18' ]; then
add-apt-repository universe > /dev/null 2>&1
echo -ne '\n' | add-apt-repository ppa:certbot/certbot > /dev/null 2>&1
fi
apt-get update > /dev/null 2>&1
apt-get -y install certbot > /dev/null 2>&1
if [ -e /usr/bin/certbot ] || [ -e /usr/local/bin/certbot ]; then
if [ ! -e /usr/bin/certbot ]; then
ln -s /usr/local/bin/certbot /usr/bin/certbot
fi
echoG 'Install CertBot finished'
else
echoR 'Please check CertBot'
fi
}
install_phpmyadmin(){
if [ ! -f ${PHPCONF}/changelog.php ]; then
cd /tmp/
echoG 'Download phpmyadmin'
wget -q https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip
unzip phpMyAdmin-latest-all-languages.zip > /dev/null 2>&1
rm -f phpMyAdmin-latest-all-languages.zip
echoG "move phpmyadmin to ${PHPCONF}"
mv phpMyAdmin-*-all-languages ${PHPCONF}
mv ${PHPCONF}/config.sample.inc.php ${PHPCONF}/config.inc.php
fi
change_owner ${PHPCONF}
}
install_wp_cli(){
if [ -e /usr/local/bin/wp ]; then
echoG 'WP CLI already exist'
else
echoG "Install wp_cli"
curl -sO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
fi
if [ ! -f /usr/bin/php ]; then
ln -s ${LSWSFD}/lsphp${PHPVER}/bin/php /usr/bin/php
fi
}
centos_config_ols(){
echoG 'Setting Web Server config'
yum -y install --reinstall openlitespeed > /dev/null 2>&1
NEWKEY=' vhRoot /var/www/html'
linechange 'www/html' ${LSWSCONF} "${NEWKEY}"
sed -i '/errorlog logs\/error.log/a \ \ \ \ \ \ \ \ keepDays 1' ${LSWSCONF}
sed -i 's/maxStaleAge 200/maxStaleAge 0/g' ${LSWSCONF}
cat > ${WPVHCONF} <<END
docRoot ${DOCLAND}/
index {
useServer 0
indexFiles index.php index.html
}
context /phpmyadmin/ {
location ${PHPCONF}/
allowBrowse 1
indexFiles index.php
accessControl {
allow *
}
rewrite {
enable 0
inherit 0
}
addDefaultCharset off
phpIniOverride {
}
}
rewrite {
enable 1
autoLoadHtaccess 1
}
END
echoG 'Finish Web Server config'
}
ubuntu_config_ols(){
echoG 'Setting Web Server config'
sed -i "s/nobody/${USER}/g" ${LSWSCONF}
sed -i "s/nogroup/${GROUP}/g" ${LSWSCONF}
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::='--force-confdef' \
-o Dpkg::Options::='--force-confold' -y install --reinstall openlitespeed > /dev/null 2>&1
NEWKEY=' vhRoot /var/www/html'
linechange 'www/html' ${LSWSCONF} "${NEWKEY}"
sed -i '/errorlog logs\/error.log/a \ \ \ \ \ \ \ \ keepDays 1' ${LSWSCONF}
sed -i 's/maxStaleAge 200/maxStaleAge 0/g' ${LSWSCONF}
cat > ${WPVHCONF} <<END
docRoot ${DOCLAND}/
index {
useServer 0
indexFiles index.php index.html
}
context /phpmyadmin/ {
location ${PHPCONF}
allowBrowse 1
indexFiles index.php
accessControl {
allow *
}
rewrite {
enable 0
inherit 0
}
addDefaultCharset off
phpIniOverride {
}
}
rewrite {
enable 1
autoLoadHtaccess 1
}
END
echoG 'Finish Web Server config'
}
landing_pg(){
echoG 'Setting Landing Page'
curl -s https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Static/wp-landing.html \
-o ${DOCLAND}/index.html
if [ -e ${DOCLAND}/index.html ]; then
echoG 'Landing Page finished'
else
echoR "Please check Landing Page here ${DOCLAND}/index.html"
fi
}
update_final_permission(){
change_owner ${DOCHM}
change_owner /tmp/lshttpd/lsphp.sock*
rm -f /tmp/lshttpd/.rtreport
rm -f /tmp/lshttpd/.status
}
ubuntu_config_memcached(){
echoG 'Setting Object Cache'
service memcached stop > /dev/null 2>&1
cat >> "${MEMCACHECONF}" <<END
-s /var/www/memcached.sock
-a 0770
-p /tmp/memcached.pid
END
NEWKEY="-u ${USER}"
linechange '\-u memcache' ${MEMCACHECONF} "${NEWKEY}"
systemctl daemon-reload > /dev/null 2>&1
service memcached start > /dev/null 2>&1
}
ubuntu_config_redis(){
service redis-server stop > /dev/null 2>&1
NEWKEY="Group=${GROUP}"
linechange 'Group=' ${REDISSERVICE} "${NEWKEY}"
cat >> "${REDISCONF}" <<END
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 775
END
BIND_LINE=$(grep -n -m 1 '^bind 127' ${REDISCONF} | awk -F ':' '{print $1}')
sed -i "${BIND_LINE}s/::1//" ${REDISCONF}
systemctl daemon-reload > /dev/null 2>&1
service redis-server start > /dev/null 2>&1
echoG 'Finish Object Cache'
}
centos_config_memcached(){
echoG 'Setting Object Cache'
service memcached stop > /dev/null 2>&1
cat >> "${MEMCACHESERVICE}" <<END
[Unit]
Description=Memcached
Before=httpd.service
After=network.target
[Service]
User=${USER}
Group=${GROUP}
Type=simple
EnvironmentFile=-/etc/sysconfig/memcached
ExecStart=/usr/bin/memcached -u \$USER -p \$PORT -m \$CACHESIZE -c \$MAXCONN \$OPTIONS
[Install]
WantedBy=multi-user.target
END
cat > "${MEMCACHECONF}" <<END
PORT="11211"
USER="${USER}"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-s /var/www/memcached.sock -a 0770 -U 0 -l 127.0.0.1"
END
### SELINUX permissive Mode
if [ ! -f /usr/sbin/semanage ]; then
yum install -y policycoreutils-python-utils > /dev/null 2>&1
fi
semanage permissive -a memcached_t
setsebool -P httpd_can_network_memcache 1
systemctl daemon-reload > /dev/null
service memcached start > /dev/null
}
centos_config_redis(){
service redis stop > /dev/null 2>&1
NEWKEY="Group=${GROUP}"
linechange 'Group=' ${REDISSERVICE} "${NEWKEY}"
cat >> "${REDISCONF}" <<END
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 775
END
BIND_LINE=$(grep -n -m 1 '^bind 127' ${REDISCONF} | awk -F ':' '{print $1}')
sed -i "${BIND_LINE}s/::1//" ${REDISCONF}
systemctl daemon-reload > /dev/null
service redis start > /dev/null
echoG 'Finish Object Cache'
}
config_mysql(){
echoG 'Setting DataBase'
get_sql_ver
if [ -f ${DBPASSPATH} ]; then
EXISTSQLPASS=$(grep root_mysql_passs ${HMPATH}/.db_password | awk -F '"' '{print $2}');
fi
if [ "${EXISTSQLPASS}" = '' ]; then
if (( ${SQL_MAINV} >=10 )) && (( ${SQL_SECV} >=4 )); then
mysql -u root -p${root_mysql_pass} \
-e "ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD('${root_mysql_pass}');"
else
mysql -u root -p${root_mysql_pass} \
-e "update mysql.user set authentication_string=password('${root_mysql_pass}') where user='root';"
fi
else
if (( ${SQL_MAINV} >=10 )) && (( ${SQL_SECV} >=4)); then
mysql -u root -p${EXISTSQLPASS} \
-e "ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD('${root_mysql_pass}');"
else
mysql -u root -p${EXISTSQLPASS} \
-e "update mysql.user set authentication_string=password('${root_mysql_pass}') where user='root';"
fi
fi
#if [ -e ${MARIADBSERVICE} ]; then
# grep -i LogLevelMax ${MARIADBSERVICE} >/dev/null 2>&1
# if [ ${?} = 1 ]; then
# echo 'LogLevelMax=1' >> ${MARIADBSERVICE}
# fi
#fi
#if [ ! -e ${MARIADBCNF} ]; then
#touch ${MARIADBCNF}
#cat > ${MARIADBCNF} <<END
#[mysqld]
#sql_mode="NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER"
#END
# fi
systemctl daemon-reload > /dev/null 2>&1
systemctl restart mariadb > /dev/null
echoG 'Finish DataBase'
}
install_wp_plugin(){
echoG 'Setting WordPress'
for PLUGIN in ${PLUGINLIST}; do
echoG "Install ${PLUGIN}"
wget -q -P ${DOCHM}/wp-content/plugins/ https://downloads.wordpress.org/plugin/${PLUGIN}
if [ $? = 0 ]; then
unzip -qq -o ${DOCHM}/wp-content/plugins/${PLUGIN} -d ${DOCHM}/wp-content/plugins/
else
echoR "${PLUGINLIST} FAILED to download"
fi
done
rm -f ${DOCHM}/wp-content/plugins/*.zip
}
set_htaccess(){
if [ ! -f ${DOCHM}/.htaccess ]; then
touch ${DOCHM}/.htaccess
fi
cat << EOM > ${DOCHM}/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
EOM
}
get_theme_name(){
THEME_NAME=$(grep WP_DEFAULT_THEME ${DOCHM}/wp-includes/default-constants.php | grep -v '!' | awk -F "'" '{print $4}')
echo "${THEME_NAME}" | grep 'twenty' >/dev/null 2>&1
if [ ${?} = 0 ]; then
THEME="${THEME_NAME}"
fi
}
set_lscache(){
cat << EOM > "${WPCONSTCONF}"
;
; This is the predefined default LSCWP configuration file
;
; All the keys and values please refer \`src/const.cls.php\`
;
; Comments start with \`;\`
;
;; -------------------------------------------------- ;;
;; -------------- General ----------------- ;;
;; -------------------------------------------------- ;;
; O_AUTO_UPGRADE
auto_upgrade = true
; O_API_KEY
api_key = ''
; O_SERVER_IP
server_ip = ''
; O_GUEST
guest = false
; O_GUEST_OPTM
guest_optm = false
; O_NEWS
news = true
; O_GUEST_UAS
guest_uas = 'Lighthouse
GTmetrix
Google
Pingdom
bot
PTST
HeadlessChrome'
; O_GUEST_IPS
guest_ips = '208.70.247.157
172.255.48.130
172.255.48.131
172.255.48.132
172.255.48.133
172.255.48.134
172.255.48.135
172.255.48.136
172.255.48.137
172.255.48.138
172.255.48.139
172.255.48.140
172.255.48.141
172.255.48.142
172.255.48.143
172.255.48.144
172.255.48.145
172.255.48.146
172.255.48.147
52.229.122.240
104.214.72.101
13.66.7.11
13.85.24.83
13.85.24.90
13.85.82.26
40.74.242.253
40.74.243.13
40.74.243.176
104.214.48.247
157.55.189.189
104.214.110.135
70.37.83.240
65.52.36.250
13.78.216.56
52.162.212.163
23.96.34.105
65.52.113.236
172.255.61.34
172.255.61.35
172.255.61.36
172.255.61.37
172.255.61.38
172.255.61.39
172.255.61.40
104.41.2.19
191.235.98.164
191.235.99.221
191.232.194.51
52.237.235.185
52.237.250.73
52.237.236.145
104.211.143.8
104.211.165.53
52.172.14.87
40.83.89.214
52.175.57.81
20.188.63.151
20.52.36.49
52.246.165.153
51.144.102.233
13.76.97.224
102.133.169.66
52.231.199.170
13.53.162.7
40.123.218.94'
;; -------------------------------------------------- ;;
;; -------------- Cache ----------------- ;;
;; -------------------------------------------------- ;;
cache-priv = true
cache-commenter = true
cache-rest = true
cache-page_login = true
cache-favicon = true
cache-resources = true
cache-browser = true
cache-mobile = false
cache-mobile_rules = 'Mobile
Android
Silk/
Kindle
BlackBerry
Opera Mini
Opera Mobi'
cache-exc_useragents = ''
cache-exc_cookies = ''
cache-exc_qs = ''
cache-exc_cat = ''
cache-exc_tag = ''
cache-force_uri = ''
cache-force_pub_uri = ''
cache-priv_uri = ''
cache-exc = ''
cache-exc_roles = ''
cache-drop_qs = 'fbclid
gclid
utm*
_ga'
cache-ttl_pub = 604800
cache-ttl_priv = 1800
cache-ttl_frontpage = 604800
cache-ttl_feed = 604800
; O_CACHE_TTL_REST
cache-ttl_rest = 604800
cache-ttl_browser = 31557600
cache-login_cookie = ''
cache-vary_group = ''
cache-ttl_status = '403 3600
404 3600
500 3600'
;; -------------------------------------------------- ;;
;; -------------- Purge ----------------- ;;
;; -------------------------------------------------- ;;
; O_PURGE_ON_UPGRADE
purge-upgrade = true
; O_PURGE_STALE
purge-stale = false
purge-post_all = false
purge-post_f = true
purge-post_h = true
purge-post_p = true
purge-post_pwrp = true
purge-post_a = true
purge-post_y = false
purge-post_m = true
purge-post_d = false
purge-post_t = true
purge-post_pt = true
purge-timed_urls = ''
purge-timed_urls_time = ''
purge-hook_all = 'switch_theme
wp_create_nav_menu
wp_update_nav_menu
wp_delete_nav_menu
create_term
edit_terms
delete_term
add_link
edit_link
delete_link'
;; -------------------------------------------------- ;;
;; -------------- ESI ----------------- ;;
;; -------------------------------------------------- ;;
; O_ESI
esi = false
; O_ESI_CACHE_ADMBAR
esi-cache_admbar = true
; O_ESI_CACHE_COMMFORM
esi-cache_commform = true
; O_ESI_NONCE
esi-nonce = 'stats_nonce
subscribe_nonce'
;; -------------------------------------------------- ;;
;; -------------- Utilities ----------------- ;;
;; -------------------------------------------------- ;;
util-heartbeat = true
util-instant_click = false
util-no_https_vary = false
;; -------------------------------------------------- ;;
;; -------------- Debug ----------------- ;;
;; -------------------------------------------------- ;;
; O_DEBUG_DISABLE_ALL
debug-disable_all = false
; O_DEBUG
debug = false
; O_DEBUG_IPS
debug-ips = '127.0.0.1'
; O_DEBUG_LEVEL
debug-level = false
; O_DEBUG_FILESIZE
debug-filesize = 3
; O_DEBUG_COOKIE
debug-cookie = false
; O_DEBUG_COLLAPS_QS
debug-collaps_qs = false
; O_DEBUG_INC
debug-inc = ''
; O_DEBUG_EXC
debug-exc = ''
;; -------------------------------------------------- ;;
;; -------------- DB Optm ----------------- ;;
;; -------------------------------------------------- ;;
; O_DB_OPTM_REVISIONS_MAX
db_optm-revisions_max = 0
; O_DB_OPTM_REVISIONS_AGE
db_optm-revisions_age = 0
;; -------------------------------------------------- ;;
;; -------------- HTML Optm ----------------- ;;
;; -------------------------------------------------- ;;
; O_OPTM_CSS_MIN
optm-css_min = false
; O_OPTM_CSS_COMB
optm-css_comb = false
; O_OPTM_CSS_COMB_EXT_INL
optm-css_comb_ext_inl = true
; O_OPTM_UCSS
optm-ucss = false
; O_OPTM_UCSS_INLINE
optm-ucss_inline = false
; O_OPTM_UCSS_FILE_EXC_INLINE
optm-ucss_file_exc_inline = ''
; O_OPTM_UCSS_SELECTOR_WHITELIST
optm-ucss_whitelist = ''
; O_OPTM_UCSS_EXC
optm-ucss_exc = ''
optm-css_exc = ''
; O_OPTM_JS_MIN
optm-js_min = false
; O_OPTM_JS_COMB
optm-js_comb = false
; O_OPTM_JS_COMB_EXT_INL
optm-js_comb_ext_inl = true
optm-js_exc = 'jquery.js
jquery.min.js'
optm-html_min = false
; O_OPTM_HTML_LAZY
optm-html_lazy=''
optm-qs_rm = false
optm-ggfonts_rm = false
; O_OPTM_CSS_ASYNC
optm-css_async = false
; O_OPTM_CCSS_PER_URL
optm-ccss_per_url = false
; O_OPTM_CSS_ASYNC_INLINE
optm-css_async_inline = true
; O_OPTM_CSS_FONT_DISPLAY
optm-css_font_display = false
; O_OPTM_JS_DEFER
optm-js_defer = false
; O_OPTM_EMOJI_RM
optm-emoji_rm = false
; O_OPTM_NOSCRIPT_RM
optm-noscript_rm = false
optm-ggfonts_async = false
optm-exc_roles = ''
optm-ccss_con = ''
; O_OPTM_CCSS_SEP_POSTTYPE
optm-ccss_sep_posttype = 'page'
; O_OPTM_CCSS_SEP_URI
optm-ccss_sep_uri = ''
; Analytics JS also measure the load-time as it is being loaded on the website itself and Google sends a report each month to the user. If these files are deferred, The Analytics JS shows a longer page-load time, even if the website isn't actually slow. by Shivam
optm-js_defer_exc = 'jquery.js
jquery.min.js
gtm.js
analytics.js'
; O_OPTM_GM_JS_EXC
optm-gm_js_exc = ''
; O_OPTM_DNS_PREFETCH
optm-dns_prefetch = ''
; O_OPTM_DNS_PREFETCH_CTRL
optm-dns_prefetch_ctrl = false
optm-exc = ''
; O_OPTM_GUEST_ONLY
optm-guest_only = true
;; -------------------------------------------------- ;;
;; -------------- Object Cache ----------------- ;;
;; -------------------------------------------------- ;;
object = true
object-kind = false
;object-host = 'localhost'
object-host = '/var/www/memcached.sock'
;object-port = 11211
cache_object_port = ''
object-life = 360
object-persistent = true
object-admin = true