diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index ddc8859e..a18a28ce 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -9,8 +9,6 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -args=("$@") - readonly setupVars="/etc/pihole/setupVars.conf" readonly dnsmasqconfig="/etc/dnsmasq.d/01-pihole.conf" readonly dhcpconfig="/etc/dnsmasq.d/02-pihole-dhcp.conf" @@ -275,30 +273,35 @@ ResolutionSettings() { fi } -case "${args[1]}" in - "-p" | "password" ) SetWebPassword;; - "-c" | "celsius" ) unit="C"; SetTemperatureUnit;; - "-f" | "fahrenheit" ) unit="F"; SetTemperatureUnit;; - "-k" | "kelvin" ) unit="K"; SetTemperatureUnit;; - "setdns" ) SetDNSServers;; - "setexcludedomains" ) SetExcludeDomains;; - "setexcludeclients" ) SetExcludeClients;; - "reboot" ) Reboot;; - "restartdns" ) RestartDNS;; - "setquerylog" ) SetQueryLogOptions;; - "enabledhcp" ) EnableDHCP;; - "disabledhcp" ) DisableDHCP;; - "layout" ) SetWebUILayout;; - "-h" | "--help" ) helpFunc;; - "domainname" ) SetDHCPDomainName;; - "privacymode" ) SetPrivacyMode;; - "resolve" ) ResolutionSettings;; - * ) helpFunc;; -esac +main() { -shift + args=("$@") -if [[ $# = 0 ]]; then - helpFunc -fi + case "${args[1]}" in + "-p" | "password" ) SetWebPassword;; + "-c" | "celsius" ) unit="C"; SetTemperatureUnit;; + "-f" | "fahrenheit" ) unit="F"; SetTemperatureUnit;; + "-k" | "kelvin" ) unit="K"; SetTemperatureUnit;; + "setdns" ) SetDNSServers;; + "setexcludedomains" ) SetExcludeDomains;; + "setexcludeclients" ) SetExcludeClients;; + "reboot" ) Reboot;; + "restartdns" ) RestartDNS;; + "setquerylog" ) SetQueryLogOptions;; + "enabledhcp" ) EnableDHCP;; + "disabledhcp" ) DisableDHCP;; + "layout" ) SetWebUILayout;; + "-h" | "--help" ) helpFunc;; + "domainname" ) SetDHCPDomainName;; + "privacymode" ) SetPrivacyMode;; + "resolve" ) ResolutionSettings;; + * ) helpFunc;; + esac + shift + + if [[ $# = 0 ]]; then + helpFunc + fi + +} diff --git a/pihole b/pihole index 5a54fae4..f41f7ac5 100755 --- a/pihole +++ b/pihole @@ -23,7 +23,8 @@ if [[ ! $EUID -eq 0 ]];then fi webpageFunc() { - /opt/pihole/webpage.sh "$@" + source /opt/pihole/webpage.sh + main "$@" exit 0 }