feat:移除openlitespeed多余脚本

This commit is contained in:
okxlin 2023-08-14 23:55:15 +08:00
parent 46d209590d
commit 2155d4c8a6
27 changed files with 0 additions and 2337 deletions

View File

@ -1,293 +0,0 @@
#!/usr/bin/env bash
EMAIL=''
NO_EMAIL=''
DOMAIN=''
INSTALL=''
UNINSTALL=''
TYPE=0
CONT_NAME='litespeed'
ACME_SRC='https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh'
EPACE=' '
RENEW=''
RENEW_ALL=''
FORCE=''
REVOKE=''
REMOVE=''
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
case ${1} in
"1")
echo 'You will need to install acme script at the first time.'
echo 'Please run acme.sh --install --email example@example.com'
;;
"2")
echo -e "\033[1mOPTIONS\033[0m"
echow '-D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: acme.sh --domain example.com"
echo "${EPACE}${EPACE}will auto detect and apply for both example.com and www.example.com domains."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
echo -e "\033[1m Only for the First time\033[0m"
echow '--install --email [EMAIL_ADDR]'
echo "${EPACE}${EPACE}Will install ACME with the Email provided"
echow '-r, --renew'
echo "${EPACE}${EPACE}Renew a specific domain with -D or --domain parameter if posibile. To force renew, use -f parameter."
echow '-R, --renew-all'
echo "${EPACE}${EPACE}Renew all domains if possible. To force renew, use -f parameter."
echow '-f, -F, --force'
echo "${EPACE}${EPACE}Force renew for a specific domain or all domains."
echow '-v, --revoke'
echo "${EPACE}${EPACE}Revoke a domain."
echow '-V, --remove'
echo "${EPACE}${EPACE}Remove a domain."
exit 0
;;
"3")
echo 'Please run acme.sh --domain [DOMAIN_NAME] to apply certificate'
exit 0
;;
esac
}
check_input(){
if [ -z "${1}" ]; then
help_message 2
fi
}
domain_filter(){
if [ -z "${1}" ]; then
help_message 3
fi
DOMAIN="${1}"
DOMAIN="${DOMAIN#http://}"
DOMAIN="${DOMAIN#https://}"
DOMAIN="${DOMAIN#ftp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#sftp://}"
DOMAIN=${DOMAIN%%/*}
}
email_filter(){
CKREG="^[a-z0-9!#\$%&'*+/=?^_\`{|}~-]+(\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\$"
if [[ "${1}" =~ ${CKREG} ]] ; then
echo -e "[O] The E-mail \033[32m${1}\033[0m is valid."
else
echo -e "[X] The E-mail \e[31m${1}\e[39m is invalid"
exit 1
fi
}
cert_hook(){
echo '[Start] Adding ACME hook'
docker compose exec ${CONT_NAME} su -s /bin/bash -c "certhookctl.sh"
echo '[End] Adding ACME hook'
}
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 -e "[O] The domain name \033[32m${DOMAIN}\033[0m is accessible."
TYPE=1
curl -Is http://${WWW_DOMAIN}/ | grep -i LiteSpeed > /dev/null 2>&1
if [ ${?} = 0 ]; then
echo -e "[O] The domain name \033[32m${WWW_DOMAIN}\033[0m is accessible."
TYPE=2
else
echo -e "[!] The domain name ${WWW_DOMAIN} is inaccessible."
fi
else
echo -e "[X] The domain name \e[31m${DOMAIN}\e[39m is inaccessible, please verify."
exit 1
fi
}
install_acme(){
echo '[Start] Install ACME'
if [ "${1}" = 'true' ]; then
docker compose exec litespeed su -c "cd; wget ${ACME_SRC}; chmod 755 acme.sh; \
./acme.sh --install --cert-home ~/.acme.sh/certs; \
rm ~/acme.sh"
elif [ "${2}" != '' ]; then
email_filter "${2}"
docker compose exec litespeed su -c "cd; wget ${ACME_SRC}; chmod 755 acme.sh; \
./acme.sh --install --cert-home ~/.acme.sh/certs --accountemail ${2}; \
rm ~/acme.sh"
else
help_message 1
exit 1
fi
echo '[End] Install ACME'
}
uninstall_acme(){
echo '[Start] Uninstall ACME'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --uninstall"
echo '[End] Uninstall ACME'
exit 0
}
check_acme(){
echo '[Start] Checking ACME'
docker compose exec ${CONT_NAME} su -c "test -f /root/.acme.sh/acme.sh"
if [ ${?} != 0 ]; then
install_acme "${NO_EMAIL}" "${EMAIL}"
cert_hook
help_message 3
fi
echo '[End] Checking ACME'
}
lsws_restart(){
docker compose exec ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
}
doc_root_verify(){
if [ "${DOC_ROOT}" = '' ]; then
DOC_PATH="/var/www/vhosts/${1}/html"
else
DOC_PATH="${DOC_ROOT}"
fi
docker compose exec ${CONT_NAME} su -c "[ -e ${DOC_PATH} ]"
if [ ${?} -eq 0 ]; then
echo -e "[O] The document root folder \033[32m${DOC_PATH}\033[0m does exist."
else
echo -e "[X] The document root folder \e[31m${DOC_PATH}\e[39m does not exist!"
exit 1
fi
}
install_cert(){
echo '[Start] Apply Lets Encrypt Certificate'
if [ ${TYPE} = 1 ]; then
docker compose exec ${CONT_NAME} su -c "/root/.acme.sh/acme.sh --issue -d ${1} -w ${DOC_PATH}"
elif [ ${TYPE} = 2 ]; then
docker compose exec ${CONT_NAME} su -c "/root/.acme.sh/acme.sh --issue -d ${1} -d www.${1} -w ${DOC_PATH}"
else
echo 'unknown Type!'
exit 2
fi
echo '[End] Apply Lets Encrypt Certificate'
}
renew_acme(){
echo '[Start] Renew ACME'
if [ "${FORCE}" = 'true' ]; then
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew --domain ${1} --force"
else
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew --domain ${1}"
fi
echo '[End] Renew ACME'
lsws_restart
}
renew_all_acme(){
echo '[Start] Renew all ACME'
if [ "${FORCE}" = 'true' ]; then
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew-all --force"
else
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew-all"
fi
echo '[End] Renew all ACME'
lsws_restart
}
revoke(){
echo '[Start] Revoke a domain'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --revoke --domain ${1}"
echo '[End] Revoke a domain'
lsws_restart
}
remove(){
echo '[Start] Remove a domain'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --remove --domain ${1}"
echo '[End] Remove a domain'
lsws_restart
}
main(){
if [ "${RENEW_ALL}" = 'true' ]; then
renew_all_acme
exit 0
elif [ "${RENEW}" = 'true' ]; then
renew_acme ${DOMAIN}
exit 0
elif [ "${REVOKE}" = 'true' ]; then
revoke ${DOMAIN}
exit 0
elif [ "${REMOVE}" = 'true' ]; then
remove ${DOMAIN}
exit 0
fi
check_acme
domain_filter ${DOMAIN}
www_domain ${DOMAIN}
domain_verify
doc_root_verify ${DOMAIN}
install_cert ${DOMAIN}
lsws_restart
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message 2
;;
-[dD] | -domain | --domain) shift
check_input "${1}"
DOMAIN="${1}"
;;
-[iI] | --install )
INSTALL=true
;;
-[uU] | --uninstall )
UNINSTALL=true
uninstall_acme
;;
-[fF] | --force )
FORCE=true
;;
-[r] | --renew )
RENEW=true
;;
-[R] | --renew-all )
RENEW_ALL=true
;;
-[v] | --revoke )
REVOKE=true
;;
-[V] | --remove )
REMOVE=true
;;
-[eE] | --email ) shift
check_input "${1}"
EMAIL="${1}"
;;
*)
help_message 2
;;
esac
shift
done
main

View File

@ -1,60 +0,0 @@
#!/usr/bin/env bash
APP_NAME=''
DOMAIN=''
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '-A, --app [app_name] -D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: appinstall.sh -A wordpress -D example.com"
echo "${EPACE}${EPACE}Will install WordPress CMS under the example.com domain"
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
app_download(){
docker compose exec litespeed su -c "appinstallctl.sh --app ${1} --domain ${2}"
bash bin/webadmin.sh -r
exit 0
}
main(){
app_download ${APP_NAME} ${DOMAIN}
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[aA] | -app | --app) shift
check_input "${1}"
APP_NAME="${1}"
;;
-[dD] | -domain | --domain) shift
check_input "${1}"
DOMAIN="${1}"
;;
*)
help_message
;;
esac
shift
done
main

View File

@ -1,158 +0,0 @@
#!/usr/bin/env bash
source .env
DOMAIN=''
SQL_DB=''
SQL_USER=''
SQL_PASS=''
ANY="'%'"
SET_OK=0
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '-D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: database.sh -D example.com"
echo "${EPACE}${EPACE}Will auto generate Database/username/password for the domain"
echow '-D, --domain [DOMAIN_NAME] -U, --user [xxx] -P, --password [xxx] -DB, --database [xxx]'
echo "${EPACE}${EPACE}Example: database.sh -D example.com -U USERNAME -P PASSWORD -DB DATABASENAME"
echo "${EPACE}${EPACE}Will create Database/username/password by given"
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
specify_name(){
check_input ${SQL_USER}
check_input ${SQL_PASS}
check_input ${SQL_DB}
}
auto_name(){
SQL_DB="${TRANSNAME}"
SQL_USER="${TRANSNAME}"
SQL_PASS="'${RANDOM_PASS}'"
}
gen_pass(){
RANDOM_PASS="$(openssl rand -base64 12)"
}
trans_name(){
TRANSNAME=$(echo ${1} | tr -d '.&&-')
}
display_credential(){
if [ ${SET_OK} = 0 ]; then
echo "Database: ${SQL_DB}"
echo "Username: ${SQL_USER}"
echo "Password: $(echo ${SQL_PASS} | tr -d "'")"
fi
}
store_credential(){
if [ -d "./sites/${1}" ]; then
if [ -f ./sites/${1}/.db_pass ]; then
mv ./sites/${1}/.db_pass ./sites/${1}/.db_pass.bk
fi
cat > "./sites/${1}/.db_pass" << EOT
"Database":"${SQL_DB}"
"Username":"${SQL_USER}"
"Password":"$(echo ${SQL_PASS} | tr -d "'")"
EOT
else
echo "./sites/${1} not found, abort credential store!"
fi
}
check_db_access(){
docker compose exec -T mysql su -c "mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e 'status'" >/dev/null 2>&1
if [ ${?} != 0 ]; then
echo '[X] DB access failed, please check!'
exit 1
fi
}
check_db_exist(){
docker compose exec -T mysql su -c "test -e /var/lib/mysql/${1}"
if [ ${?} = 0 ]; then
echo "Database ${1} already exist, skip DB creation!"
exit 0
fi
}
db_setup(){
docker compose exec -T mysql su -c 'mysql -uroot -p${MYSQL_ROOT_PASSWORD} \
-e "CREATE DATABASE '${SQL_DB}';" \
-e "GRANT ALL PRIVILEGES ON '${SQL_DB}'.* TO '${SQL_USER}'@'${ANY}' IDENTIFIED BY '${SQL_PASS}';" \
-e "FLUSH PRIVILEGES;"'
SET_OK=${?}
}
auto_setup_main(){
check_input ${DOMAIN}
gen_pass
trans_name ${DOMAIN}
auto_name
check_db_exist ${SQL_DB}
check_db_access
db_setup
display_credential
store_credential ${DOMAIN}
}
specify_setup_main(){
specify_name
check_db_exist ${SQL_DB}
check_db_access
db_setup
display_credential
store_credential ${DOMAIN}
}
main(){
if [ "${SQL_USER}" != '' ] && [ "${SQL_PASS}" != '' ] && [ "${SQL_DB}" != '' ]; then
specify_setup_main
else
auto_setup_main
fi
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[dD] | -domain| --domain) shift
DOMAIN="${1}"
;;
-[uU] | -user | --user) shift
SQL_USER="${1}"
;;
-[pP] | -password| --password) shift
SQL_PASS="'${1}'"
;;
-db | -DB | -database| --database) shift
SQL_DB="${1}"
;;
*)
help_message
;;
esac
shift
done
main

View File

@ -1,102 +0,0 @@
#!/usr/bin/env bash
source .env
APP_NAME='wordpress'
CONT_NAME='litespeed'
DOC_FD=''
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
case ${1} in
"1")
echow "Script will get 'DOMAIN' and 'database' info from .env file, then auto setup virtual host and the wordpress site for you."
exit 0
;;
"2")
echow 'Service finished, enjoy your accelarated LiteSpeed server!'
;;
esac
}
domain_filter(){
if [ ! -n "${DOMAIN}" ]; then
echo "Parameters not supplied, please check!"
exit 1
fi
DOMAIN="${1}"
DOMAIN="${DOMAIN#http://}"
DOMAIN="${DOMAIN#https://}"
DOMAIN="${DOMAIN#ftp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#sftp://}"
DOMAIN=${DOMAIN%%/*}
}
gen_root_fd(){
DOC_FD="./sites/${1}/"
if [ -d "./sites/${1}" ]; then
echo -e "[O] The root folder \033[32m${DOC_FD}\033[0m exist."
else
echo "Creating - document root."
bash bin/domain.sh -add ${1}
echo "Finished - document root."
fi
}
create_db(){
if [ ! -n "${MYSQL_DATABASE}" ] || [ ! -n "${MYSQL_USER}" ] || [ ! -n "${MYSQL_PASSWORD}" ]; then
echo "Parameters not supplied, please check!"
exit 1
else
bash bin/database.sh -D ${1} -U ${MYSQL_USER} -P ${MYSQL_PASSWORD} -DB ${MYSQL_DATABASE}
fi
}
store_credential(){
if [ -f ${DOC_FD}/.db_pass ]; then
echo '[O] db file exist!'
else
echo 'Storing database parameter'
cat > "${DOC_FD}/.db_pass" << EOT
"Database":"${MYSQL_DATABASE}"
"Username":"${MYSQL_USER}"
"Password":"$(echo ${MYSQL_PASSWORD} | tr -d "'")"
EOT
fi
}
app_download(){
docker compose exec -T ${CONT_NAME} su -c "appinstallctl.sh --app ${1} --domain ${2}"
}
lsws_restart(){
bash bin/webadmin.sh -r
}
main(){
domain_filter ${DOMAIN}
gen_root_fd ${DOMAIN}
create_db ${DOMAIN}
store_credential
app_download ${APP_NAME} ${DOMAIN}
lsws_restart
help_message 2
}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message 1
;;
*)
help_message 1
;;
esac
shift
done
main

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
git ls-files -v|grep '^S'

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
find conf -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --no-skip-worktree" \;

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
find conf -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --skip-worktree" \;

View File

@ -1,61 +0,0 @@
#!/usr/bin/env bash
CONT_NAME='litespeed'
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow "-A, --add [domain_name]"
echo "${EPACE}${EPACE}Example: domain.sh -A example.com, will add the domain to Listener and auto create a new virtual host."
echow "-D, --del [domain_name]"
echo "${EPACE}${EPACE}Example: domain.sh -D example.com, will delete the domain from Listener."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
add_domain(){
check_input ${1}
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
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}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[aA] | -add | --add) shift
add_domain ${1}
;;
-[dD] | -del | --del | --delete) shift
del_domain ${1}
;;
*)
help_message
;;
esac
shift
done

View File

@ -1,98 +0,0 @@
#!/usr/bin/env bash
CONT_NAME='litespeed'
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '[Enter Your PASSWORD]'
echo "${EPACE}${EPACE}Example: webadmin.sh MY_SECURE_PASS, to update web admin password immediatly."
echow '-R, --restart'
echo "${EPACE}${EPACE}Will gracefully restart LiteSpeed Web Server."
echow '-M, --mod-secure [enable|disable]'
echo "${EPACE}${EPACE}Example: webadmin.sh -M enable, will enable and apply Mod_Secure OWASP rules on server"
echow '-U, --upgrade'
echo "${EPACE}${EPACE}Will upgrade web server to latest stable version"
echow '-S, --serial [YOUR_SERIAL|TRIAL]'
echo "${EPACE}${EPACE}Will apply your serial number to LiteSpeed Web Server."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
lsws_restart(){
docker compose exec -T ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
}
apply_serial(){
docker compose exec ${CONT_NAME} su -c "serialctl.sh --serial ${1}"
lsws_restart
}
mod_secure(){
if [ "${1}" = 'enable' ] || [ "${1}" = 'Enable' ]; then
docker compose exec ${CONT_NAME} su -s /bin/bash root -c "owaspctl.sh --enable"
lsws_restart
elif [ "${1}" = 'disable' ] || [ "${1}" = 'Disable' ]; then
docker compose exec ${CONT_NAME} su -s /bin/bash root -c "owaspctl.sh --disable"
lsws_restart
else
help_message
fi
}
ls_upgrade(){
echo 'Upgrade web server to latest stable version.'
docker compose exec ${CONT_NAME} su -c '/usr/local/lsws/admin/misc/lsup.sh 2>/dev/null'
}
set_web_admin(){
echo 'Update web admin password.'
local LSADPATH='/usr/local/lsws/admin'
docker compose exec ${CONT_NAME} su -s /bin/bash lsadm -c \
'if [ -e /usr/local/lsws/admin/fcgi-bin/admin_php ]; then \
echo "admin:$('${LSADPATH}'/fcgi-bin/admin_php -q '${LSADPATH}'/misc/htpasswd.php '${1}')" > '${LSADPATH}'/conf/htpasswd; \
else echo "admin:$('${LSADPATH}'/fcgi-bin/admin_php5 -q '${LSADPATH}'/misc/htpasswd.php '${1}')" > '${LSADPATH}'/conf/htpasswd; \
fi';
}
main(){
set_web_admin ${1}
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[rR] | -restart | --restart)
lsws_restart
;;
-M | -mode-secure | --mod-secure) shift
mod_secure ${1}
;;
-lsup | --lsup | --upgrade | -U) shift
ls_upgrade
;;
-[sS] | -serial | --serial) shift
apply_serial ${1}
;;
*)
main ${1}
;;
esac
shift
done

View File

@ -1,293 +0,0 @@
#!/usr/bin/env bash
EMAIL=''
NO_EMAIL=''
DOMAIN=''
INSTALL=''
UNINSTALL=''
TYPE=0
CONT_NAME='litespeed'
ACME_SRC='https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh'
EPACE=' '
RENEW=''
RENEW_ALL=''
FORCE=''
REVOKE=''
REMOVE=''
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
case ${1} in
"1")
echo 'You will need to install acme script at the first time.'
echo 'Please run acme.sh --install --email example@example.com'
;;
"2")
echo -e "\033[1mOPTIONS\033[0m"
echow '-D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: acme.sh --domain example.com"
echo "${EPACE}${EPACE}will auto detect and apply for both example.com and www.example.com domains."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
echo -e "\033[1m Only for the First time\033[0m"
echow '--install --email [EMAIL_ADDR]'
echo "${EPACE}${EPACE}Will install ACME with the Email provided"
echow '-r, --renew'
echo "${EPACE}${EPACE}Renew a specific domain with -D or --domain parameter if posibile. To force renew, use -f parameter."
echow '-R, --renew-all'
echo "${EPACE}${EPACE}Renew all domains if possible. To force renew, use -f parameter."
echow '-f, -F, --force'
echo "${EPACE}${EPACE}Force renew for a specific domain or all domains."
echow '-v, --revoke'
echo "${EPACE}${EPACE}Revoke a domain."
echow '-V, --remove'
echo "${EPACE}${EPACE}Remove a domain."
exit 0
;;
"3")
echo 'Please run acme.sh --domain [DOMAIN_NAME] to apply certificate'
exit 0
;;
esac
}
check_input(){
if [ -z "${1}" ]; then
help_message 2
fi
}
domain_filter(){
if [ -z "${1}" ]; then
help_message 3
fi
DOMAIN="${1}"
DOMAIN="${DOMAIN#http://}"
DOMAIN="${DOMAIN#https://}"
DOMAIN="${DOMAIN#ftp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#sftp://}"
DOMAIN=${DOMAIN%%/*}
}
email_filter(){
CKREG="^[a-z0-9!#\$%&'*+/=?^_\`{|}~-]+(\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\$"
if [[ "${1}" =~ ${CKREG} ]] ; then
echo -e "[O] The E-mail \033[32m${1}\033[0m is valid."
else
echo -e "[X] The E-mail \e[31m${1}\e[39m is invalid"
exit 1
fi
}
cert_hook(){
echo '[Start] Adding ACME hook'
docker compose exec ${CONT_NAME} su -s /bin/bash -c "certhookctl.sh"
echo '[End] Adding ACME hook'
}
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 -e "[O] The domain name \033[32m${DOMAIN}\033[0m is accessible."
TYPE=1
curl -Is http://${WWW_DOMAIN}/ | grep -i LiteSpeed > /dev/null 2>&1
if [ ${?} = 0 ]; then
echo -e "[O] The domain name \033[32m${WWW_DOMAIN}\033[0m is accessible."
TYPE=2
else
echo -e "[!] The domain name ${WWW_DOMAIN} is inaccessible."
fi
else
echo -e "[X] The domain name \e[31m${DOMAIN}\e[39m is inaccessible, please verify."
exit 1
fi
}
install_acme(){
echo '[Start] Install ACME'
if [ "${1}" = 'true' ]; then
docker compose exec litespeed su -c "cd; wget ${ACME_SRC}; chmod 755 acme.sh; \
./acme.sh --install --cert-home ~/.acme.sh/certs; \
rm ~/acme.sh"
elif [ "${2}" != '' ]; then
email_filter "${2}"
docker compose exec litespeed su -c "cd; wget ${ACME_SRC}; chmod 755 acme.sh; \
./acme.sh --install --cert-home ~/.acme.sh/certs --accountemail ${2}; \
rm ~/acme.sh"
else
help_message 1
exit 1
fi
echo '[End] Install ACME'
}
uninstall_acme(){
echo '[Start] Uninstall ACME'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --uninstall"
echo '[End] Uninstall ACME'
exit 0
}
check_acme(){
echo '[Start] Checking ACME'
docker compose exec ${CONT_NAME} su -c "test -f /root/.acme.sh/acme.sh"
if [ ${?} != 0 ]; then
install_acme "${NO_EMAIL}" "${EMAIL}"
cert_hook
help_message 3
fi
echo '[End] Checking ACME'
}
lsws_restart(){
docker compose exec ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
}
doc_root_verify(){
if [ "${DOC_ROOT}" = '' ]; then
DOC_PATH="/var/www/vhosts/${1}/html"
else
DOC_PATH="${DOC_ROOT}"
fi
docker compose exec ${CONT_NAME} su -c "[ -e ${DOC_PATH} ]"
if [ ${?} -eq 0 ]; then
echo -e "[O] The document root folder \033[32m${DOC_PATH}\033[0m does exist."
else
echo -e "[X] The document root folder \e[31m${DOC_PATH}\e[39m does not exist!"
exit 1
fi
}
install_cert(){
echo '[Start] Apply Lets Encrypt Certificate'
if [ ${TYPE} = 1 ]; then
docker compose exec ${CONT_NAME} su -c "/root/.acme.sh/acme.sh --issue -d ${1} -w ${DOC_PATH}"
elif [ ${TYPE} = 2 ]; then
docker compose exec ${CONT_NAME} su -c "/root/.acme.sh/acme.sh --issue -d ${1} -d www.${1} -w ${DOC_PATH}"
else
echo 'unknown Type!'
exit 2
fi
echo '[End] Apply Lets Encrypt Certificate'
}
renew_acme(){
echo '[Start] Renew ACME'
if [ "${FORCE}" = 'true' ]; then
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew --domain ${1} --force"
else
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew --domain ${1}"
fi
echo '[End] Renew ACME'
lsws_restart
}
renew_all_acme(){
echo '[Start] Renew all ACME'
if [ "${FORCE}" = 'true' ]; then
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew-all --force"
else
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew-all"
fi
echo '[End] Renew all ACME'
lsws_restart
}
revoke(){
echo '[Start] Revoke a domain'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --revoke --domain ${1}"
echo '[End] Revoke a domain'
lsws_restart
}
remove(){
echo '[Start] Remove a domain'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --remove --domain ${1}"
echo '[End] Remove a domain'
lsws_restart
}
main(){
if [ "${RENEW_ALL}" = 'true' ]; then
renew_all_acme
exit 0
elif [ "${RENEW}" = 'true' ]; then
renew_acme ${DOMAIN}
exit 0
elif [ "${REVOKE}" = 'true' ]; then
revoke ${DOMAIN}
exit 0
elif [ "${REMOVE}" = 'true' ]; then
remove ${DOMAIN}
exit 0
fi
check_acme
domain_filter ${DOMAIN}
www_domain ${DOMAIN}
domain_verify
doc_root_verify ${DOMAIN}
install_cert ${DOMAIN}
lsws_restart
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message 2
;;
-[dD] | -domain | --domain) shift
check_input "${1}"
DOMAIN="${1}"
;;
-[iI] | --install )
INSTALL=true
;;
-[uU] | --uninstall )
UNINSTALL=true
uninstall_acme
;;
-[fF] | --force )
FORCE=true
;;
-[r] | --renew )
RENEW=true
;;
-[R] | --renew-all )
RENEW_ALL=true
;;
-[v] | --revoke )
REVOKE=true
;;
-[V] | --remove )
REMOVE=true
;;
-[eE] | --email ) shift
check_input "${1}"
EMAIL="${1}"
;;
*)
help_message 2
;;
esac
shift
done
main

View File

@ -1,60 +0,0 @@
#!/usr/bin/env bash
APP_NAME=''
DOMAIN=''
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '-A, --app [app_name] -D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: appinstall.sh -A wordpress -D example.com"
echo "${EPACE}${EPACE}Will install WordPress CMS under the example.com domain"
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
app_download(){
docker compose exec litespeed su -c "appinstallctl.sh --app ${1} --domain ${2}"
bash bin/webadmin.sh -r
exit 0
}
main(){
app_download ${APP_NAME} ${DOMAIN}
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[aA] | -app | --app) shift
check_input "${1}"
APP_NAME="${1}"
;;
-[dD] | -domain | --domain) shift
check_input "${1}"
DOMAIN="${1}"
;;
*)
help_message
;;
esac
shift
done
main

View File

@ -1,158 +0,0 @@
#!/usr/bin/env bash
source .env
DOMAIN=''
SQL_DB=''
SQL_USER=''
SQL_PASS=''
ANY="'%'"
SET_OK=0
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '-D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: database.sh -D example.com"
echo "${EPACE}${EPACE}Will auto generate Database/username/password for the domain"
echow '-D, --domain [DOMAIN_NAME] -U, --user [xxx] -P, --password [xxx] -DB, --database [xxx]'
echo "${EPACE}${EPACE}Example: database.sh -D example.com -U USERNAME -P PASSWORD -DB DATABASENAME"
echo "${EPACE}${EPACE}Will create Database/username/password by given"
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
specify_name(){
check_input ${SQL_USER}
check_input ${SQL_PASS}
check_input ${SQL_DB}
}
auto_name(){
SQL_DB="${TRANSNAME}"
SQL_USER="${TRANSNAME}"
SQL_PASS="'${RANDOM_PASS}'"
}
gen_pass(){
RANDOM_PASS="$(openssl rand -base64 12)"
}
trans_name(){
TRANSNAME=$(echo ${1} | tr -d '.&&-')
}
display_credential(){
if [ ${SET_OK} = 0 ]; then
echo "Database: ${SQL_DB}"
echo "Username: ${SQL_USER}"
echo "Password: $(echo ${SQL_PASS} | tr -d "'")"
fi
}
store_credential(){
if [ -d "./sites/${1}" ]; then
if [ -f ./sites/${1}/.db_pass ]; then
mv ./sites/${1}/.db_pass ./sites/${1}/.db_pass.bk
fi
cat > "./sites/${1}/.db_pass" << EOT
"Database":"${SQL_DB}"
"Username":"${SQL_USER}"
"Password":"$(echo ${SQL_PASS} | tr -d "'")"
EOT
else
echo "./sites/${1} not found, abort credential store!"
fi
}
check_db_access(){
docker compose exec -T mysql su -c "mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e 'status'" >/dev/null 2>&1
if [ ${?} != 0 ]; then
echo '[X] DB access failed, please check!'
exit 1
fi
}
check_db_exist(){
docker compose exec -T mysql su -c "test -e /var/lib/mysql/${1}"
if [ ${?} = 0 ]; then
echo "Database ${1} already exist, skip DB creation!"
exit 0
fi
}
db_setup(){
docker compose exec -T mysql su -c 'mysql -uroot -p${MYSQL_ROOT_PASSWORD} \
-e "CREATE DATABASE '${SQL_DB}';" \
-e "GRANT ALL PRIVILEGES ON '${SQL_DB}'.* TO '${SQL_USER}'@'${ANY}' IDENTIFIED BY '${SQL_PASS}';" \
-e "FLUSH PRIVILEGES;"'
SET_OK=${?}
}
auto_setup_main(){
check_input ${DOMAIN}
gen_pass
trans_name ${DOMAIN}
auto_name
check_db_exist ${SQL_DB}
check_db_access
db_setup
display_credential
store_credential ${DOMAIN}
}
specify_setup_main(){
specify_name
check_db_exist ${SQL_DB}
check_db_access
db_setup
display_credential
store_credential ${DOMAIN}
}
main(){
if [ "${SQL_USER}" != '' ] && [ "${SQL_PASS}" != '' ] && [ "${SQL_DB}" != '' ]; then
specify_setup_main
else
auto_setup_main
fi
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[dD] | -domain| --domain) shift
DOMAIN="${1}"
;;
-[uU] | -user | --user) shift
SQL_USER="${1}"
;;
-[pP] | -password| --password) shift
SQL_PASS="'${1}'"
;;
-db | -DB | -database| --database) shift
SQL_DB="${1}"
;;
*)
help_message
;;
esac
shift
done
main

View File

@ -1,102 +0,0 @@
#!/usr/bin/env bash
source .env
APP_NAME='wordpress'
CONT_NAME='litespeed'
DOC_FD=''
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
case ${1} in
"1")
echow "Script will get 'DOMAIN' and 'database' info from .env file, then auto setup virtual host and the wordpress site for you."
exit 0
;;
"2")
echow 'Service finished, enjoy your accelarated LiteSpeed server!'
;;
esac
}
domain_filter(){
if [ ! -n "${DOMAIN}" ]; then
echo "Parameters not supplied, please check!"
exit 1
fi
DOMAIN="${1}"
DOMAIN="${DOMAIN#http://}"
DOMAIN="${DOMAIN#https://}"
DOMAIN="${DOMAIN#ftp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#sftp://}"
DOMAIN=${DOMAIN%%/*}
}
gen_root_fd(){
DOC_FD="./sites/${1}/"
if [ -d "./sites/${1}" ]; then
echo -e "[O] The root folder \033[32m${DOC_FD}\033[0m exist."
else
echo "Creating - document root."
bash bin/domain.sh -add ${1}
echo "Finished - document root."
fi
}
create_db(){
if [ ! -n "${MYSQL_DATABASE}" ] || [ ! -n "${MYSQL_USER}" ] || [ ! -n "${MYSQL_PASSWORD}" ]; then
echo "Parameters not supplied, please check!"
exit 1
else
bash bin/database.sh -D ${1} -U ${MYSQL_USER} -P ${MYSQL_PASSWORD} -DB ${MYSQL_DATABASE}
fi
}
store_credential(){
if [ -f ${DOC_FD}/.db_pass ]; then
echo '[O] db file exist!'
else
echo 'Storing database parameter'
cat > "${DOC_FD}/.db_pass" << EOT
"Database":"${MYSQL_DATABASE}"
"Username":"${MYSQL_USER}"
"Password":"$(echo ${MYSQL_PASSWORD} | tr -d "'")"
EOT
fi
}
app_download(){
docker compose exec -T ${CONT_NAME} su -c "appinstallctl.sh --app ${1} --domain ${2}"
}
lsws_restart(){
bash bin/webadmin.sh -r
}
main(){
domain_filter ${DOMAIN}
gen_root_fd ${DOMAIN}
create_db ${DOMAIN}
store_credential
app_download ${APP_NAME} ${DOMAIN}
lsws_restart
help_message 2
}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message 1
;;
*)
help_message 1
;;
esac
shift
done
main

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
git ls-files -v|grep '^S'

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
find conf -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --no-skip-worktree" \;

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
find conf -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --skip-worktree" \;

View File

@ -1,61 +0,0 @@
#!/usr/bin/env bash
CONT_NAME='litespeed'
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow "-A, --add [domain_name]"
echo "${EPACE}${EPACE}Example: domain.sh -A example.com, will add the domain to Listener and auto create a new virtual host."
echow "-D, --del [domain_name]"
echo "${EPACE}${EPACE}Example: domain.sh -D example.com, will delete the domain from Listener."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
add_domain(){
check_input ${1}
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
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}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[aA] | -add | --add) shift
add_domain ${1}
;;
-[dD] | -del | --del | --delete) shift
del_domain ${1}
;;
*)
help_message
;;
esac
shift
done

View File

@ -1,98 +0,0 @@
#!/usr/bin/env bash
CONT_NAME='litespeed'
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '[Enter Your PASSWORD]'
echo "${EPACE}${EPACE}Example: webadmin.sh MY_SECURE_PASS, to update web admin password immediatly."
echow '-R, --restart'
echo "${EPACE}${EPACE}Will gracefully restart LiteSpeed Web Server."
echow '-M, --mod-secure [enable|disable]'
echo "${EPACE}${EPACE}Example: webadmin.sh -M enable, will enable and apply Mod_Secure OWASP rules on server"
echow '-U, --upgrade'
echo "${EPACE}${EPACE}Will upgrade web server to latest stable version"
echow '-S, --serial [YOUR_SERIAL|TRIAL]'
echo "${EPACE}${EPACE}Will apply your serial number to LiteSpeed Web Server."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
lsws_restart(){
docker compose exec -T ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
}
apply_serial(){
docker compose exec ${CONT_NAME} su -c "serialctl.sh --serial ${1}"
lsws_restart
}
mod_secure(){
if [ "${1}" = 'enable' ] || [ "${1}" = 'Enable' ]; then
docker compose exec ${CONT_NAME} su -s /bin/bash root -c "owaspctl.sh --enable"
lsws_restart
elif [ "${1}" = 'disable' ] || [ "${1}" = 'Disable' ]; then
docker compose exec ${CONT_NAME} su -s /bin/bash root -c "owaspctl.sh --disable"
lsws_restart
else
help_message
fi
}
ls_upgrade(){
echo 'Upgrade web server to latest stable version.'
docker compose exec ${CONT_NAME} su -c '/usr/local/lsws/admin/misc/lsup.sh 2>/dev/null'
}
set_web_admin(){
echo 'Update web admin password.'
local LSADPATH='/usr/local/lsws/admin'
docker compose exec ${CONT_NAME} su -s /bin/bash lsadm -c \
'if [ -e /usr/local/lsws/admin/fcgi-bin/admin_php ]; then \
echo "admin:$('${LSADPATH}'/fcgi-bin/admin_php -q '${LSADPATH}'/misc/htpasswd.php '${1}')" > '${LSADPATH}'/conf/htpasswd; \
else echo "admin:$('${LSADPATH}'/fcgi-bin/admin_php5 -q '${LSADPATH}'/misc/htpasswd.php '${1}')" > '${LSADPATH}'/conf/htpasswd; \
fi';
}
main(){
set_web_admin ${1}
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[rR] | -restart | --restart)
lsws_restart
;;
-M | -mode-secure | --mod-secure) shift
mod_secure ${1}
;;
-lsup | --lsup | --upgrade | -U) shift
ls_upgrade
;;
-[sS] | -serial | --serial) shift
apply_serial ${1}
;;
*)
main ${1}
;;
esac
shift
done

View File

@ -1,293 +0,0 @@
#!/usr/bin/env bash
EMAIL=''
NO_EMAIL=''
DOMAIN=''
INSTALL=''
UNINSTALL=''
TYPE=0
CONT_NAME='litespeed'
ACME_SRC='https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh'
EPACE=' '
RENEW=''
RENEW_ALL=''
FORCE=''
REVOKE=''
REMOVE=''
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
case ${1} in
"1")
echo 'You will need to install acme script at the first time.'
echo 'Please run acme.sh --install --email example@example.com'
;;
"2")
echo -e "\033[1mOPTIONS\033[0m"
echow '-D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: acme.sh --domain example.com"
echo "${EPACE}${EPACE}will auto detect and apply for both example.com and www.example.com domains."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
echo -e "\033[1m Only for the First time\033[0m"
echow '--install --email [EMAIL_ADDR]'
echo "${EPACE}${EPACE}Will install ACME with the Email provided"
echow '-r, --renew'
echo "${EPACE}${EPACE}Renew a specific domain with -D or --domain parameter if posibile. To force renew, use -f parameter."
echow '-R, --renew-all'
echo "${EPACE}${EPACE}Renew all domains if possible. To force renew, use -f parameter."
echow '-f, -F, --force'
echo "${EPACE}${EPACE}Force renew for a specific domain or all domains."
echow '-v, --revoke'
echo "${EPACE}${EPACE}Revoke a domain."
echow '-V, --remove'
echo "${EPACE}${EPACE}Remove a domain."
exit 0
;;
"3")
echo 'Please run acme.sh --domain [DOMAIN_NAME] to apply certificate'
exit 0
;;
esac
}
check_input(){
if [ -z "${1}" ]; then
help_message 2
fi
}
domain_filter(){
if [ -z "${1}" ]; then
help_message 3
fi
DOMAIN="${1}"
DOMAIN="${DOMAIN#http://}"
DOMAIN="${DOMAIN#https://}"
DOMAIN="${DOMAIN#ftp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#sftp://}"
DOMAIN=${DOMAIN%%/*}
}
email_filter(){
CKREG="^[a-z0-9!#\$%&'*+/=?^_\`{|}~-]+(\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\$"
if [[ "${1}" =~ ${CKREG} ]] ; then
echo -e "[O] The E-mail \033[32m${1}\033[0m is valid."
else
echo -e "[X] The E-mail \e[31m${1}\e[39m is invalid"
exit 1
fi
}
cert_hook(){
echo '[Start] Adding ACME hook'
docker compose exec ${CONT_NAME} su -s /bin/bash -c "certhookctl.sh"
echo '[End] Adding ACME hook'
}
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 -e "[O] The domain name \033[32m${DOMAIN}\033[0m is accessible."
TYPE=1
curl -Is http://${WWW_DOMAIN}/ | grep -i LiteSpeed > /dev/null 2>&1
if [ ${?} = 0 ]; then
echo -e "[O] The domain name \033[32m${WWW_DOMAIN}\033[0m is accessible."
TYPE=2
else
echo -e "[!] The domain name ${WWW_DOMAIN} is inaccessible."
fi
else
echo -e "[X] The domain name \e[31m${DOMAIN}\e[39m is inaccessible, please verify."
exit 1
fi
}
install_acme(){
echo '[Start] Install ACME'
if [ "${1}" = 'true' ]; then
docker compose exec litespeed su -c "cd; wget ${ACME_SRC}; chmod 755 acme.sh; \
./acme.sh --install --cert-home ~/.acme.sh/certs; \
rm ~/acme.sh"
elif [ "${2}" != '' ]; then
email_filter "${2}"
docker compose exec litespeed su -c "cd; wget ${ACME_SRC}; chmod 755 acme.sh; \
./acme.sh --install --cert-home ~/.acme.sh/certs --accountemail ${2}; \
rm ~/acme.sh"
else
help_message 1
exit 1
fi
echo '[End] Install ACME'
}
uninstall_acme(){
echo '[Start] Uninstall ACME'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --uninstall"
echo '[End] Uninstall ACME'
exit 0
}
check_acme(){
echo '[Start] Checking ACME'
docker compose exec ${CONT_NAME} su -c "test -f /root/.acme.sh/acme.sh"
if [ ${?} != 0 ]; then
install_acme "${NO_EMAIL}" "${EMAIL}"
cert_hook
help_message 3
fi
echo '[End] Checking ACME'
}
lsws_restart(){
docker compose exec ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
}
doc_root_verify(){
if [ "${DOC_ROOT}" = '' ]; then
DOC_PATH="/var/www/vhosts/${1}/html"
else
DOC_PATH="${DOC_ROOT}"
fi
docker compose exec ${CONT_NAME} su -c "[ -e ${DOC_PATH} ]"
if [ ${?} -eq 0 ]; then
echo -e "[O] The document root folder \033[32m${DOC_PATH}\033[0m does exist."
else
echo -e "[X] The document root folder \e[31m${DOC_PATH}\e[39m does not exist!"
exit 1
fi
}
install_cert(){
echo '[Start] Apply Lets Encrypt Certificate'
if [ ${TYPE} = 1 ]; then
docker compose exec ${CONT_NAME} su -c "/root/.acme.sh/acme.sh --issue -d ${1} -w ${DOC_PATH}"
elif [ ${TYPE} = 2 ]; then
docker compose exec ${CONT_NAME} su -c "/root/.acme.sh/acme.sh --issue -d ${1} -d www.${1} -w ${DOC_PATH}"
else
echo 'unknown Type!'
exit 2
fi
echo '[End] Apply Lets Encrypt Certificate'
}
renew_acme(){
echo '[Start] Renew ACME'
if [ "${FORCE}" = 'true' ]; then
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew --domain ${1} --force"
else
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew --domain ${1}"
fi
echo '[End] Renew ACME'
lsws_restart
}
renew_all_acme(){
echo '[Start] Renew all ACME'
if [ "${FORCE}" = 'true' ]; then
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew-all --force"
else
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew-all"
fi
echo '[End] Renew all ACME'
lsws_restart
}
revoke(){
echo '[Start] Revoke a domain'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --revoke --domain ${1}"
echo '[End] Revoke a domain'
lsws_restart
}
remove(){
echo '[Start] Remove a domain'
docker compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --remove --domain ${1}"
echo '[End] Remove a domain'
lsws_restart
}
main(){
if [ "${RENEW_ALL}" = 'true' ]; then
renew_all_acme
exit 0
elif [ "${RENEW}" = 'true' ]; then
renew_acme ${DOMAIN}
exit 0
elif [ "${REVOKE}" = 'true' ]; then
revoke ${DOMAIN}
exit 0
elif [ "${REMOVE}" = 'true' ]; then
remove ${DOMAIN}
exit 0
fi
check_acme
domain_filter ${DOMAIN}
www_domain ${DOMAIN}
domain_verify
doc_root_verify ${DOMAIN}
install_cert ${DOMAIN}
lsws_restart
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message 2
;;
-[dD] | -domain | --domain) shift
check_input "${1}"
DOMAIN="${1}"
;;
-[iI] | --install )
INSTALL=true
;;
-[uU] | --uninstall )
UNINSTALL=true
uninstall_acme
;;
-[fF] | --force )
FORCE=true
;;
-[r] | --renew )
RENEW=true
;;
-[R] | --renew-all )
RENEW_ALL=true
;;
-[v] | --revoke )
REVOKE=true
;;
-[V] | --remove )
REMOVE=true
;;
-[eE] | --email ) shift
check_input "${1}"
EMAIL="${1}"
;;
*)
help_message 2
;;
esac
shift
done
main

View File

@ -1,60 +0,0 @@
#!/usr/bin/env bash
APP_NAME=''
DOMAIN=''
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '-A, --app [app_name] -D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: appinstall.sh -A wordpress -D example.com"
echo "${EPACE}${EPACE}Will install WordPress CMS under the example.com domain"
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
app_download(){
docker compose exec litespeed su -c "appinstallctl.sh --app ${1} --domain ${2}"
bash bin/webadmin.sh -r
exit 0
}
main(){
app_download ${APP_NAME} ${DOMAIN}
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[aA] | -app | --app) shift
check_input "${1}"
APP_NAME="${1}"
;;
-[dD] | -domain | --domain) shift
check_input "${1}"
DOMAIN="${1}"
;;
*)
help_message
;;
esac
shift
done
main

View File

@ -1,158 +0,0 @@
#!/usr/bin/env bash
source .env
DOMAIN=''
SQL_DB=''
SQL_USER=''
SQL_PASS=''
ANY="'%'"
SET_OK=0
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '-D, --domain [DOMAIN_NAME]'
echo "${EPACE}${EPACE}Example: database.sh -D example.com"
echo "${EPACE}${EPACE}Will auto generate Database/username/password for the domain"
echow '-D, --domain [DOMAIN_NAME] -U, --user [xxx] -P, --password [xxx] -DB, --database [xxx]'
echo "${EPACE}${EPACE}Example: database.sh -D example.com -U USERNAME -P PASSWORD -DB DATABASENAME"
echo "${EPACE}${EPACE}Will create Database/username/password by given"
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
specify_name(){
check_input ${SQL_USER}
check_input ${SQL_PASS}
check_input ${SQL_DB}
}
auto_name(){
SQL_DB="${TRANSNAME}"
SQL_USER="${TRANSNAME}"
SQL_PASS="'${RANDOM_PASS}'"
}
gen_pass(){
RANDOM_PASS="$(openssl rand -base64 12)"
}
trans_name(){
TRANSNAME=$(echo ${1} | tr -d '.&&-')
}
display_credential(){
if [ ${SET_OK} = 0 ]; then
echo "Database: ${SQL_DB}"
echo "Username: ${SQL_USER}"
echo "Password: $(echo ${SQL_PASS} | tr -d "'")"
fi
}
store_credential(){
if [ -d "./sites/${1}" ]; then
if [ -f ./sites/${1}/.db_pass ]; then
mv ./sites/${1}/.db_pass ./sites/${1}/.db_pass.bk
fi
cat > "./sites/${1}/.db_pass" << EOT
"Database":"${SQL_DB}"
"Username":"${SQL_USER}"
"Password":"$(echo ${SQL_PASS} | tr -d "'")"
EOT
else
echo "./sites/${1} not found, abort credential store!"
fi
}
check_db_access(){
docker compose exec -T mysql su -c "mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e 'status'" >/dev/null 2>&1
if [ ${?} != 0 ]; then
echo '[X] DB access failed, please check!'
exit 1
fi
}
check_db_exist(){
docker compose exec -T mysql su -c "test -e /var/lib/mysql/${1}"
if [ ${?} = 0 ]; then
echo "Database ${1} already exist, skip DB creation!"
exit 0
fi
}
db_setup(){
docker compose exec -T mysql su -c 'mysql -uroot -p${MYSQL_ROOT_PASSWORD} \
-e "CREATE DATABASE '${SQL_DB}';" \
-e "GRANT ALL PRIVILEGES ON '${SQL_DB}'.* TO '${SQL_USER}'@'${ANY}' IDENTIFIED BY '${SQL_PASS}';" \
-e "FLUSH PRIVILEGES;"'
SET_OK=${?}
}
auto_setup_main(){
check_input ${DOMAIN}
gen_pass
trans_name ${DOMAIN}
auto_name
check_db_exist ${SQL_DB}
check_db_access
db_setup
display_credential
store_credential ${DOMAIN}
}
specify_setup_main(){
specify_name
check_db_exist ${SQL_DB}
check_db_access
db_setup
display_credential
store_credential ${DOMAIN}
}
main(){
if [ "${SQL_USER}" != '' ] && [ "${SQL_PASS}" != '' ] && [ "${SQL_DB}" != '' ]; then
specify_setup_main
else
auto_setup_main
fi
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[dD] | -domain| --domain) shift
DOMAIN="${1}"
;;
-[uU] | -user | --user) shift
SQL_USER="${1}"
;;
-[pP] | -password| --password) shift
SQL_PASS="'${1}'"
;;
-db | -DB | -database| --database) shift
SQL_DB="${1}"
;;
*)
help_message
;;
esac
shift
done
main

View File

@ -1,102 +0,0 @@
#!/usr/bin/env bash
source .env
APP_NAME='wordpress'
CONT_NAME='litespeed'
DOC_FD=''
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
case ${1} in
"1")
echow "Script will get 'DOMAIN' and 'database' info from .env file, then auto setup virtual host and the wordpress site for you."
exit 0
;;
"2")
echow 'Service finished, enjoy your accelarated LiteSpeed server!'
;;
esac
}
domain_filter(){
if [ ! -n "${DOMAIN}" ]; then
echo "Parameters not supplied, please check!"
exit 1
fi
DOMAIN="${1}"
DOMAIN="${DOMAIN#http://}"
DOMAIN="${DOMAIN#https://}"
DOMAIN="${DOMAIN#ftp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#scp://}"
DOMAIN="${DOMAIN#sftp://}"
DOMAIN=${DOMAIN%%/*}
}
gen_root_fd(){
DOC_FD="./sites/${1}/"
if [ -d "./sites/${1}" ]; then
echo -e "[O] The root folder \033[32m${DOC_FD}\033[0m exist."
else
echo "Creating - document root."
bash bin/domain.sh -add ${1}
echo "Finished - document root."
fi
}
create_db(){
if [ ! -n "${MYSQL_DATABASE}" ] || [ ! -n "${MYSQL_USER}" ] || [ ! -n "${MYSQL_PASSWORD}" ]; then
echo "Parameters not supplied, please check!"
exit 1
else
bash bin/database.sh -D ${1} -U ${MYSQL_USER} -P ${MYSQL_PASSWORD} -DB ${MYSQL_DATABASE}
fi
}
store_credential(){
if [ -f ${DOC_FD}/.db_pass ]; then
echo '[O] db file exist!'
else
echo 'Storing database parameter'
cat > "${DOC_FD}/.db_pass" << EOT
"Database":"${MYSQL_DATABASE}"
"Username":"${MYSQL_USER}"
"Password":"$(echo ${MYSQL_PASSWORD} | tr -d "'")"
EOT
fi
}
app_download(){
docker compose exec -T ${CONT_NAME} su -c "appinstallctl.sh --app ${1} --domain ${2}"
}
lsws_restart(){
bash bin/webadmin.sh -r
}
main(){
domain_filter ${DOMAIN}
gen_root_fd ${DOMAIN}
create_db ${DOMAIN}
store_credential
app_download ${APP_NAME} ${DOMAIN}
lsws_restart
help_message 2
}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message 1
;;
*)
help_message 1
;;
esac
shift
done
main

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
git ls-files -v|grep '^S'

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
find conf -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --no-skip-worktree" \;

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
find conf -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --skip-worktree" \;

View File

@ -1,61 +0,0 @@
#!/usr/bin/env bash
CONT_NAME='litespeed'
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow "-A, --add [domain_name]"
echo "${EPACE}${EPACE}Example: domain.sh -A example.com, will add the domain to Listener and auto create a new virtual host."
echow "-D, --del [domain_name]"
echo "${EPACE}${EPACE}Example: domain.sh -D example.com, will delete the domain from Listener."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
add_domain(){
check_input ${1}
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
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}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[aA] | -add | --add) shift
add_domain ${1}
;;
-[dD] | -del | --del | --delete) shift
del_domain ${1}
;;
*)
help_message
;;
esac
shift
done

View File

@ -1,98 +0,0 @@
#!/usr/bin/env bash
CONT_NAME='litespeed'
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
help_message(){
echo -e "\033[1mOPTIONS\033[0m"
echow '[Enter Your PASSWORD]'
echo "${EPACE}${EPACE}Example: webadmin.sh MY_SECURE_PASS, to update web admin password immediatly."
echow '-R, --restart'
echo "${EPACE}${EPACE}Will gracefully restart LiteSpeed Web Server."
echow '-M, --mod-secure [enable|disable]'
echo "${EPACE}${EPACE}Example: webadmin.sh -M enable, will enable and apply Mod_Secure OWASP rules on server"
echow '-U, --upgrade'
echo "${EPACE}${EPACE}Will upgrade web server to latest stable version"
echow '-S, --serial [YOUR_SERIAL|TRIAL]'
echo "${EPACE}${EPACE}Will apply your serial number to LiteSpeed Web Server."
echow '-H, --help'
echo "${EPACE}${EPACE}Display help and exit."
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
lsws_restart(){
docker compose exec -T ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
}
apply_serial(){
docker compose exec ${CONT_NAME} su -c "serialctl.sh --serial ${1}"
lsws_restart
}
mod_secure(){
if [ "${1}" = 'enable' ] || [ "${1}" = 'Enable' ]; then
docker compose exec ${CONT_NAME} su -s /bin/bash root -c "owaspctl.sh --enable"
lsws_restart
elif [ "${1}" = 'disable' ] || [ "${1}" = 'Disable' ]; then
docker compose exec ${CONT_NAME} su -s /bin/bash root -c "owaspctl.sh --disable"
lsws_restart
else
help_message
fi
}
ls_upgrade(){
echo 'Upgrade web server to latest stable version.'
docker compose exec ${CONT_NAME} su -c '/usr/local/lsws/admin/misc/lsup.sh 2>/dev/null'
}
set_web_admin(){
echo 'Update web admin password.'
local LSADPATH='/usr/local/lsws/admin'
docker compose exec ${CONT_NAME} su -s /bin/bash lsadm -c \
'if [ -e /usr/local/lsws/admin/fcgi-bin/admin_php ]; then \
echo "admin:$('${LSADPATH}'/fcgi-bin/admin_php -q '${LSADPATH}'/misc/htpasswd.php '${1}')" > '${LSADPATH}'/conf/htpasswd; \
else echo "admin:$('${LSADPATH}'/fcgi-bin/admin_php5 -q '${LSADPATH}'/misc/htpasswd.php '${1}')" > '${LSADPATH}'/conf/htpasswd; \
fi';
}
main(){
set_web_admin ${1}
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
-[rR] | -restart | --restart)
lsws_restart
;;
-M | -mode-secure | --mod-secure) shift
mod_secure ${1}
;;
-lsup | --lsup | --upgrade | -U) shift
ls_upgrade
;;
-[sS] | -serial | --serial) shift
apply_serial ${1}
;;
*)
main ${1}
;;
esac
shift
done