Files
ols-docker-env/bin/webadmin.sh
T

46 lines
992 B
Bash
Raw Normal View History

2020-01-08 20:04:10 -05:00
#!/usr/bin/env bash
2020-01-09 12:18:41 -05:00
help_message(){
echo 'Command [PASSWORD]'
2020-01-10 11:47:15 -05:00
echo 'Example: webadmin.sh mypassword'
echo 'Command [-r]'
echo 'Example: webadmin.sh -r'
echo 'Will restart LiteSpeed Web Server'
2020-01-09 12:18:41 -05:00
exit 0
}
check_input(){
if [ -z "${1}" ]; then
help_message
exit 1
fi
}
set_web_admin(){
docker-compose exec litespeed su -s /bin/bash lsadm -c \
'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';
}
2020-01-10 11:47:15 -05:00
lsws_restart(){
docker-compose exec litespeed su -c '/usr/local/lsws/bin/lswsctrl restart'
}
2020-01-09 12:18:41 -05:00
main(){
2020-01-10 11:47:15 -05:00
set_web_admin ${1}
2020-01-09 12:18:41 -05:00
}
check_input ${1}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
2020-01-10 11:47:15 -05:00
;;
-[rR] | -restart | --restart)
lsws_restart
;;
2020-01-09 12:18:41 -05:00
*)
2020-01-09 16:42:48 -05:00
main ${1}
2020-01-09 12:18:41 -05:00
;;
esac
shift
done