|
|
|
@ -6,7 +6,10 @@ APP_NAME=''
|
|
|
|
|
DOMAIN=''
|
|
|
|
|
WWW_UID=''
|
|
|
|
|
WWW_GID=''
|
|
|
|
|
WP_CONST_CONF=''
|
|
|
|
|
PUB_IP=$(curl http://checkip.amazonaws.com)
|
|
|
|
|
PLUGINLIST="litespeed-cache.zip"
|
|
|
|
|
THEME='twentytwenty'
|
|
|
|
|
|
|
|
|
|
help_message(){
|
|
|
|
|
echo 'Command [-app app_name] [-domain domain_name]'
|
|
|
|
@ -29,6 +32,24 @@ linechange(){
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ck_ed(){
|
|
|
|
|
if [ -f /bin/ed ]; then
|
|
|
|
|
echo "ed exist"
|
|
|
|
|
else
|
|
|
|
|
echo "no ed, ready to install"
|
|
|
|
|
apt-get install ed -y > /dev/null 2>&1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ck_unzip(){
|
|
|
|
|
if [ -f /usr/bin/unzip ]; then
|
|
|
|
|
echo "unzip exist"
|
|
|
|
|
else
|
|
|
|
|
echo "no unzip, ready to install"
|
|
|
|
|
apt-get install unzip -y > /dev/null 2>&1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_owner(){
|
|
|
|
|
WWW_UID=$(stat -c "%u" ${DEFAULT_VH_ROOT})
|
|
|
|
|
WWW_GID=$(stat -c "%g" ${DEFAULT_VH_ROOT})
|
|
|
|
@ -53,9 +74,11 @@ set_vh_docroot(){
|
|
|
|
|
if [ "${VHNAME}" != '' ]; then
|
|
|
|
|
VH_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}"
|
|
|
|
|
VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}/html"
|
|
|
|
|
WP_CONS_TCONF="${VH_DOC_ROOT}/wp-content/plugins/litespeed-cache/data/const.default.ini"
|
|
|
|
|
elif [ -d ${DEFAULT_VH_ROOT}/${1}/html ]; then
|
|
|
|
|
VH_ROOT="${DEFAULT_VH_ROOT}/${1}"
|
|
|
|
|
VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${1}/html"
|
|
|
|
|
WP_CONST_CONF="${VH_DOC_ROOT}/wp-content/plugins/litespeed-cache/data/const.default.ini"
|
|
|
|
|
else
|
|
|
|
|
echo "${DEFAULT_VH_ROOT}/${1}/html does not exist, please add domain first! Abort!"
|
|
|
|
|
exit 1
|
|
|
|
@ -78,6 +101,114 @@ check_sql_native(){
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
install_wp_plugin(){
|
|
|
|
|
for PLUGIN in ${PLUGINLIST}; do
|
|
|
|
|
wget -q -P ${VH_DOC_ROOT}/wp-content/plugins/ https://downloads.wordpress.org/plugin/${PLUGIN}
|
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
|
ck_unzip
|
|
|
|
|
unzip -qq -o ${VH_DOC_ROOT}/wp-content/plugins/${PLUGIN} -d ${VH_DOC_ROOT}/wp-content/plugins/
|
|
|
|
|
else
|
|
|
|
|
echo "${PLUGINLIST} FAILED to download"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
rm -f ${VH_DOC_ROOT}/wp-content/plugins/*.zip
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_htaccess(){
|
|
|
|
|
if [ ! -f ${VH_DOC_ROOT}/.htaccess ]; then
|
|
|
|
|
touch ${VH_DOC_ROOT}/.htaccess
|
|
|
|
|
fi
|
|
|
|
|
cat << EOM > ${VH_DOC_ROOT}/.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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_lscache(){
|
|
|
|
|
cat << EOM > "${WP_CONST_CONF}"
|
|
|
|
|
; This is the default LSCWP configuration file
|
|
|
|
|
; All keys and values please refer const.cls.php
|
|
|
|
|
; Here just list some examples
|
|
|
|
|
; Comments start with \`;\`
|
|
|
|
|
; OPID_PURGE_ON_UPGRADE
|
|
|
|
|
purge_upgrade = true
|
|
|
|
|
; OPID_CACHE_PRIV
|
|
|
|
|
cache_priv = true
|
|
|
|
|
; OPID_CACHE_COMMENTER
|
|
|
|
|
cache_commenter = true
|
|
|
|
|
;Object_Cache_Enable
|
|
|
|
|
cache_object = true
|
|
|
|
|
; OPID_CACHE_OBJECT_HOST
|
|
|
|
|
;cache_object_host = 'localhost'
|
|
|
|
|
cache_object_host = '/var/www/memcached.sock'
|
|
|
|
|
; OPID_CACHE_OBJECT_PORT
|
|
|
|
|
;cache_object_port = '11211'
|
|
|
|
|
cache_object_port = ''
|
|
|
|
|
auto_upgrade = true
|
|
|
|
|
; OPID_CACHE_BROWSER_TTL
|
|
|
|
|
cache_browser_ttl = 2592000
|
|
|
|
|
; OPID_PUBLIC_TTL
|
|
|
|
|
public_ttl = 604800
|
|
|
|
|
; ------------------------------CDN Mapping Example BEGIN-------------------------------
|
|
|
|
|
; Need to add the section mark \`[litespeed-cache-cdn_mapping]\` before list
|
|
|
|
|
;
|
|
|
|
|
; NOTE 1) Need to set all child options to make all resources to be replaced without missing
|
|
|
|
|
; NOTE 2) \`url[n]\` option must have to enable the row setting of \`n\`
|
|
|
|
|
;
|
|
|
|
|
; To enable the 2nd mapping record by default, please remove the \`;;\` in the related lines
|
|
|
|
|
[litespeed-cache-cdn_mapping]
|
|
|
|
|
url[0] = ''
|
|
|
|
|
inc_js[0] = true
|
|
|
|
|
inc_css[0] = true
|
|
|
|
|
inc_img[0] = true
|
|
|
|
|
filetype[0] = '.aac
|
|
|
|
|
.css
|
|
|
|
|
.eot
|
|
|
|
|
.gif
|
|
|
|
|
.jpeg
|
|
|
|
|
.js
|
|
|
|
|
.jpg
|
|
|
|
|
.less
|
|
|
|
|
.mp3
|
|
|
|
|
.mp4
|
|
|
|
|
.ogg
|
|
|
|
|
.otf
|
|
|
|
|
.pdf
|
|
|
|
|
.png
|
|
|
|
|
.svg
|
|
|
|
|
.ttf
|
|
|
|
|
.woff'
|
|
|
|
|
;;url[1] = 'https://2nd_CDN_url.com/'
|
|
|
|
|
;;filetype[1] = '.webm'
|
|
|
|
|
; ------------------------------CDN Mapping Example END-------------------------------
|
|
|
|
|
EOM
|
|
|
|
|
|
|
|
|
|
if [ ! -f ${VH_DOC_ROOT}/wp-content/themes/${THEME}/functions.php.bk ]; then
|
|
|
|
|
cp ${VH_DOC_ROOT}/wp-content/themes/${THEME}/functions.php ${VH_DOC_ROOT}/wp-content/themes/${THEME}/functions.php.bk
|
|
|
|
|
ck_ed
|
|
|
|
|
ed ${VH_DOC_ROOT}/wp-content/themes/${THEME}/functions.php << END >>/dev/null 2>&1
|
|
|
|
|
2i
|
|
|
|
|
require_once( WP_CONTENT_DIR.'/../wp-admin/includes/plugin.php' );
|
|
|
|
|
\$path = 'litespeed-cache/litespeed-cache.php' ;
|
|
|
|
|
if (!is_plugin_active( \$path )) {
|
|
|
|
|
activate_plugin( \$path ) ;
|
|
|
|
|
rename( __FILE__ . '.bk', __FILE__ );
|
|
|
|
|
}
|
|
|
|
|
.
|
|
|
|
|
w
|
|
|
|
|
q
|
|
|
|
|
END
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
preinstall_wordpress(){
|
|
|
|
|
if [ "${VHNAME}" != '' ]; then
|
|
|
|
|
get_db_pass ${VHNAME}
|
|
|
|
@ -127,6 +258,9 @@ main(){
|
|
|
|
|
check_sql_native
|
|
|
|
|
app_wordpress_dl
|
|
|
|
|
preinstall_wordpress
|
|
|
|
|
install_wp_plugin
|
|
|
|
|
set_htaccess
|
|
|
|
|
set_lscache
|
|
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
echo "APP: ${APP_NAME} not support, exit!"
|
|
|
|
|