mirror of
https://github.com/10h30/ols-docker-env.git
synced 2026-05-12 15:21:24 +09:00
scripts update
This commit is contained in:
+33
-7
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
DOMAIN=''
|
||||
TYPE=0
|
||||
|
||||
help_message(){
|
||||
echo 'Command [your_domain]'
|
||||
@@ -13,22 +14,49 @@ check_input(){
|
||||
fi
|
||||
}
|
||||
|
||||
strip_www(){
|
||||
www_domain(){
|
||||
CHECK_WWW=$(echo ${1} | cut -c1-4)
|
||||
if [[ ${CHECK_WWW} == www. ]] ; then
|
||||
DOMAIN=$(echo ${1} | cut -c 5-)
|
||||
else
|
||||
DOMAIN=${1}
|
||||
fi
|
||||
WWW_DOMAIN="www.${DOMAIN}"
|
||||
}
|
||||
|
||||
domain_verify(){
|
||||
curl -Is http://${DOMAIN}/ | grep -i LiteSpeed > /dev/null 2>&1
|
||||
if [ ${?} = 0 ]; then
|
||||
echo "[OK] ${DOMAIN} is accessible."
|
||||
TYPE=1
|
||||
curl -Is http://${WWW_DOMAIN}/ | grep -i LiteSpeed > /dev/null 2>&1
|
||||
if [ ${?} = 0 ]; then
|
||||
echo "[OK] ${WWW_DOMAIN} is accessible."
|
||||
TYPE=2
|
||||
else
|
||||
echo "${WWW_DOMAIN} is inaccessible."
|
||||
fi
|
||||
else
|
||||
echo "${MY_DOMAIN} is inaccessible, please verify."; exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
lecertapply(){
|
||||
docker-compose exec litespeed su -c "certbot certonly --agree-tos --register-unsafely-without-email \
|
||||
--non-interactive --webroot -w /var/www/vhosts/${1}/html -d ${1} -d www.${1}"
|
||||
if [ ${TYPE} = 1 ]; then
|
||||
docker-compose exec litespeed su -c "certbot certonly --agree-tos --register-unsafely-without-email \
|
||||
--non-interactive --webroot -w /var/www/vhosts/${1}/html -d ${1}"
|
||||
elif [ ${TYPE} = 2 ]; then
|
||||
docker-compose exec litespeed su -c "certbot certonly --agree-tos --register-unsafely-without-email \
|
||||
--non-interactive --webroot -w /var/www/vhosts/${1}/html -d ${1} -d www.${1}"
|
||||
else
|
||||
echo 'unknown Type!'
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
main(){
|
||||
strip_www ${1}
|
||||
www_domain ${1}
|
||||
domain_verify
|
||||
lecertapply ${DOMAIN}
|
||||
}
|
||||
|
||||
@@ -43,6 +71,4 @@ while [ ! -z "${1}" ]; do
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
done
|
||||
@@ -7,7 +7,7 @@ DOMAIN=''
|
||||
WWW_UID=''
|
||||
WWW_GID=''
|
||||
WP_CONST_CONF=''
|
||||
PUB_IP=$(curl http://checkip.amazonaws.com)
|
||||
PUB_IP=$(curl -s http://checkip.amazonaws.com)
|
||||
PLUGINLIST="litespeed-cache.zip"
|
||||
THEME='twentytwenty'
|
||||
|
||||
@@ -33,18 +33,14 @@ linechange(){
|
||||
}
|
||||
|
||||
ck_ed(){
|
||||
if [ -f /bin/ed ]; then
|
||||
echo "ed exist"
|
||||
else
|
||||
if [ ! -f /bin/ed ]; then
|
||||
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
|
||||
if [ ! -f /usr/bin/unzip ]; then
|
||||
echo "no unzip, ready to install"
|
||||
apt-get install unzip -y > /dev/null 2>&1
|
||||
fi
|
||||
@@ -239,17 +235,21 @@ app_wordpress_dl(){
|
||||
wp core download \
|
||||
--allow-root \
|
||||
--quiet
|
||||
if [ "${VHNAME}" != '' ]; then
|
||||
chown -R ${WWW_UID}:${WWW_GID} ${DEFAULT_VH_ROOT}/${VHNAME}
|
||||
else
|
||||
chown -R ${WWW_UID}:${WWW_GID} ${DEFAULT_VH_ROOT}/${DOMAIN}
|
||||
fi
|
||||
else
|
||||
echo 'wp-config*.php already exist, abort!'
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
change_owner(){
|
||||
if [ "${VHNAME}" != '' ]; then
|
||||
chown -R ${WWW_UID}:${WWW_GID} ${DEFAULT_VH_ROOT}/${VHNAME}
|
||||
else
|
||||
chown -R ${WWW_UID}:${WWW_GID} ${DEFAULT_VH_ROOT}/${DOMAIN}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main(){
|
||||
set_vh_docroot ${DOMAIN}
|
||||
get_owner
|
||||
@@ -261,6 +261,7 @@ main(){
|
||||
install_wp_plugin
|
||||
set_htaccess
|
||||
set_lscache
|
||||
change_owner
|
||||
exit 0
|
||||
else
|
||||
echo "APP: ${APP_NAME} not support, exit!"
|
||||
@@ -268,6 +269,7 @@ main(){
|
||||
fi
|
||||
}
|
||||
|
||||
check_input ${1}
|
||||
while [ ! -z "${1}" ]; do
|
||||
case ${1} in
|
||||
-[hH] | -help | --help)
|
||||
|
||||
+3
-1
@@ -19,12 +19,14 @@ add_domain(){
|
||||
docker-compose exec ${CONT_NAME} su -s /bin/bash lsadm -c "cd /usr/local/lsws/conf && domainctl.sh -add ${1}"
|
||||
if [ ! -d "./sites/${1}" ]; then
|
||||
mkdir -p ./sites/${1}/{html,logs,certs}
|
||||
fi
|
||||
fi
|
||||
bash bin/webadmin.sh -r
|
||||
}
|
||||
|
||||
del_domain(){
|
||||
check_input ${1}
|
||||
docker-compose exec ${CONT_NAME} su -s /bin/bash lsadm -c "cd /usr/local/lsws/conf && domainctl.sh -del ${1}"
|
||||
bash bin/webadmin.sh -r
|
||||
}
|
||||
|
||||
check_input ${1}
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
help_message(){
|
||||
echo 'Command [PASSWORD]'
|
||||
echo 'Example: setwebadmin.sh mypassword'
|
||||
echo 'Example: webadmin.sh mypassword'
|
||||
echo 'Command [-r]'
|
||||
echo 'Example: webadmin.sh -r'
|
||||
echo 'Will restart LiteSpeed Web Server'
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -18,8 +21,12 @@ set_web_admin(){
|
||||
'echo "admin:$(/usr/local/lsws/admin/fcgi-bin/admin_php* -q /usr/local/lsws/admin/misc/htpasswd.php '${1}')" > /usr/local/lsws/admin/conf/htpasswd';
|
||||
}
|
||||
|
||||
lsws_restart(){
|
||||
docker-compose exec litespeed su -c '/usr/local/lsws/bin/lswsctrl restart'
|
||||
}
|
||||
|
||||
main(){
|
||||
set_web_admin
|
||||
set_web_admin ${1}
|
||||
}
|
||||
|
||||
check_input ${1}
|
||||
@@ -27,7 +34,10 @@ while [ ! -z "${1}" ]; do
|
||||
case ${1} in
|
||||
-[hH] | -help | --help)
|
||||
help_message
|
||||
;;
|
||||
;;
|
||||
-[rR] | -restart | --restart)
|
||||
lsws_restart
|
||||
;;
|
||||
*)
|
||||
main ${1}
|
||||
;;
|
||||
Reference in New Issue
Block a user