You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.6 KiB

5 years ago
#!/usr/bin/env bash
5 years ago
CONT_NAME='litespeed'
5 years ago
EPACE=' '
echow(){
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}
5 years ago
help_message(){
5 years ago
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."
5 years ago
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
5 years ago
lsws_restart(){
docker-compose exec ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
5 years ago
}
5 years ago
apply_serial(){
docker-compose exec ${CONT_NAME} su -c "serialctl.sh --serial ${1}"
5 years ago
lsws_restart
}
5 years ago
mod_secure(){
if [ "${1}" = 'enable' ] || [ "${1}" = 'Enable' ]; then
docker-compose exec ${CONT_NAME} su -s /bin/bash root -c "owaspctl.sh --enable"
5 years ago
lsws_restart
elif [ "${1}" = 'disable' ] || [ "${1}" = 'Disable' ]; then
docker-compose exec ${CONT_NAME} su -s /bin/bash root -c "owaspctl.sh --disable"
5 years ago
lsws_restart
else
help_message
fi
}
5 years ago
ls_upgrade(){
5 years ago
echo 'Upgrade web server to latest stable version.'
5 years ago
docker-compose exec ${CONT_NAME} su -c '/usr/local/lsws/admin/misc/lsup.sh 2>/dev/null'
}
5 years ago
set_web_admin(){
5 years ago
echo 'Update web admin password.'
5 years ago
docker-compose exec ${CONT_NAME} su -s /bin/bash lsadm -c \
5 years ago
'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';
5 years ago
}
5 years ago
main(){
5 years ago
set_web_admin ${1}
5 years ago
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
5 years ago
;;
-[rR] | -restart | --restart)
lsws_restart
5 years ago
;;
5 years ago
-M | -mode-secure | --mod-secure) shift
5 years ago
mod_secure ${1}
;;
5 years ago
-lsup | --lsup | --upgrade | -U) shift
5 years ago
ls_upgrade
5 years ago
;;
-[sS] | -serial | --serial) shift
apply_serial ${1}
;;
5 years ago
*)
5 years ago
main ${1}
5 years ago
;;
esac
shift
done