function usage { echo "Usage: $0 [option...]" >&2 echo echo " -e, Enable MonitWebui" echo " -d, Disable MonitWebui" echo " -h, Shows this information" echo } if [ -n "$1" ]; then if [[ ! -f /etc/WebV2/toggle.conf ]]; then echo "Creating File" touch /etc/WebV2/toggle.conf fi source /etc/WebV2/toggle.conf if [ -z "$MonitWeb" ]; then echo "Creating Var" echo "MonitWeb=3" >> /etc/WebV2/toggle.conf MonitWeb=3 fi if [[ "$1" = "-d" && "$MonitWeb" != 0 ]]; then echo "Disable MonitWebui" sed -i '/MonitWeb=/c\MonitWeb=0' /etc/WebV2/toggle.conf sed -i --follow-symlinks '/#enables\/disables monit-websocket/!b;n;cdeny from all' /APADIR/sites-enabled/010-Backend.conf sed -i '/#enables\/disables monit-websocket/ s/^#*/#/' MONITCONF systemctl reload APASRV monit elif [[ "$1" = "-e" && "$MonitWeb" != 1 ]]; then echo "Enable MonitWebui" sed -i '/MonitWeb=/c\MonitWeb=1' /etc/WebV2/toggle.conf sed -i --follow-symlinks '/#enables\/disables monit-websocket/!b;n;c#deny from all' /APADIR/sites-enabled/010-Backend.conf sed -i '/#enables\/disables monit-websocket/ s/^.//' MONITCONF systemctl reload APASRV monit elif [[ "$1" = "-h" ]]; then usage else echo "Oopsie!" fi else usage fi