diff --git a/Scripts/toggles/toggle-PhpMyAdmin_NGINX.sh b/Scripts/toggles/toggle-PhpMyAdmin_NGINX.sh index 00cf64a..e7171b9 100644 --- a/Scripts/toggles/toggle-PhpMyAdmin_NGINX.sh +++ b/Scripts/toggles/toggle-PhpMyAdmin_NGINX.sh @@ -1,25 +1,37 @@ function usage { - echo "Usage: $0 [option...]" >&2 - echo - echo " -e, Enable PhpMyadmin" - echo " -d, Disable PhpMyadmin" - echo + echo "Usage: $0 [option...]" >&2 + echo + echo " -e, Enable PhpMyadmin" + echo " -d, Disable PhpMyadmin" + echo " -h, Shows this information" + echo } - - if [ -n "$1" ]; then - -if [ "$1" = "-d" ]; then - echo "Disable PhpMyadmin" - sed -i '/deny all; #enables\/disables PHPMyadmin/c\ deny all; #enables\/disables PHPMyadmin' /etc/nginx/sites-available/Backend - systemctl reload nginx -elif [ "$1" = "-e" ]; then - echo "Enable PhpMyadmin" - sed -i '/deny all; #enables\/disables PHPMyadmin/c\ #deny all; #enables\/disables PHPMyadmin' /etc/nginx/sites-available/Backend - systemctl reload nginx + if [[ ! -f /etc/ICTM/toggle.conf ]]; then + echo "Creating File" + touch /etc/ICTM/toggle.conf + fi + source /etc/ICTM/toggle.conf + if [ -z "$PhpMA" ]; then + echo "Creating Var" + echo "PhpMA=3" >> /etc/ICTM/toggle.conf + PhpMA=3 + fi + if [[ "$1" = "-d" && "$PhpMA" != 0 ]]; then + echo "Disable PhpMyadmin" + sed -i '/PhpMA=/c\PhpMA=0' /etc/ICTM/toggle.conf + sed -i '/deny all; #enables\/disables PHPMyadmin/c\ deny all; #enables\/disables PHPMyadmin' /etc/nginx/sites-available/Backend + systemctl reload nginx + elif [[ "$1" = "-e" && "$PhpMA" != 1 ]]; then + echo "Enable PhpMyadmin" + sed -i '/PhpMA=/c\PhpMA=1' /etc/ICTM/toggle.conf + sed -i '/deny all; #enables\/disables PHPMyadmin/c\ #deny all; #enables\/disables PHPMyadmin' /etc/nginx/sites-available/Backend + systemctl reload nginx + elif [[ "$1" = "-h" ]]; then + usage + else + echo "Oopsie!" + fi else usage -fi -else - usage -fi +fi \ No newline at end of file