From 1556adb678a11e1f2c66474330d515b6eb62aa99 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 14 Dec 2016 12:12:36 +0100 Subject: [PATCH 1/4] Also remove quiet-dhcp setting when disabling/enabling the Pi-Hole DHCP server --- advanced/Scripts/webpage.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 179580b4..1ee41b15 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -137,7 +137,7 @@ EnableDHCP(){ echo "DHCP_ROUTER=${args[4]}" >> /etc/pihole/setupVars.conf # Remove setting from file - sed -i '/dhcp-/d;' /etc/dnsmasq.d/01-pihole.conf + sed -i '/dhcp-/d;/quiet-dhcp/d;' /etc/dnsmasq.d/01-pihole.conf # Save setting to file echo "dhcp-range=${args[2]},${args[3]},infinite" >> /etc/dnsmasq.d/01-pihole.conf echo "dhcp-option=option:router,${args[4]}" >> /etc/dnsmasq.d/01-pihole.conf @@ -159,7 +159,7 @@ DisableDHCP(){ echo "DHCP_ACTIVE=false" >> /etc/pihole/setupVars.conf # Remove setting from file - sed -i '/dhcp-/d;' /etc/dnsmasq.d/01-pihole.conf + sed -i '/dhcp-/d;/quiet-dhcp/d;' /etc/dnsmasq.d/01-pihole.conf RestartDNS } From ba015c191845fe279ef8b5943c3b213d5dbf0f88 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 14 Dec 2016 14:24:09 +0100 Subject: [PATCH 2/4] Set domain name via Settings page --- advanced/Scripts/webpage.sh | 50 ++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 1ee41b15..4f7fa43b 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -172,23 +172,39 @@ SetWebUILayout(){ } -for var in "$@"; do - case "${var}" in - "-p" | "password" ) SetWebPassword;; - "-c" | "celsius" ) unit="C"; SetTemperatureUnit;; - "-f" | "fahrenheit" ) unit="F"; SetTemperatureUnit;; - "setdns" ) SetDNSServers;; - "setexcludedomains" ) SetExcludeDomains;; - "setexcludeclients" ) SetExcludeClients;; - "reboot" ) Reboot;; - "restartdns" ) RestartDNS;; - "setquerylog" ) SetQueryLogOptions;; - "enabledhcp" ) EnableDHCP;; - "disabledhcp" ) DisableDHCP;; - "layout" ) SetWebUILayout;; - "-h" | "--help" ) helpFunc;; - esac -done +SetDNSDomainName(){ + + # Remove setting from file (create backup setupVars.conf.bak) + sed -i.bak '/PIHOLE_DOMAIN/d;' /etc/pihole/setupVars.conf + # Save setting to file + echo "PIHOLE_DOMAIN=${args[2]}" >> /etc/pihole/setupVars.conf + + # Replace within actual dnsmasq config file + sed -i '/domain=/d;' /etc/dnsmasq.d/01-pihole.conf + echo "domain=${args[2]}" >> /etc/dnsmasq.d/01-pihole.conf + + # Restart dnsmasq to load new configuration + RestartDNS + +} + +case "${args[1]}" in + "-p" | "password" ) SetWebPassword;; + "-c" | "celsius" ) unit="C"; SetTemperatureUnit;; + "-f" | "fahrenheit" ) unit="F"; SetTemperatureUnit;; + "setdns" ) SetDNSServers;; + "setexcludedomains" ) SetExcludeDomains;; + "setexcludeclients" ) SetExcludeClients;; + "reboot" ) Reboot;; + "restartdns" ) RestartDNS;; + "setquerylog" ) SetQueryLogOptions;; + "enabledhcp" ) EnableDHCP;; + "disabledhcp" ) DisableDHCP;; + "layout" ) SetWebUILayout;; + "-h" | "--help" ) helpFunc;; + "domainname" ) SetDNSDomainName;; + * ) helpFunc;; +esac shift From 85e3f37503f0da4e85099614ea01ff5f7516051f Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 14 Dec 2016 16:09:57 +0100 Subject: [PATCH 3/4] dnsmasq "domain-needed" property --- advanced/Scripts/webpage.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 4f7fa43b..3309fc99 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -72,7 +72,7 @@ SetWebPassword(){ SetDNSServers(){ # Remove setting from file (create backup setupVars.conf.bak) - sed -i.bak '/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;' /etc/pihole/setupVars.conf + sed -i.bak '/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/DNS_FQDN_REQUIRED/d;' /etc/pihole/setupVars.conf # Save setting to file echo "PIHOLE_DNS_1=${args[2]}" >> /etc/pihole/setupVars.conf echo "PIHOLE_DNS_2=${args[3]}" >> /etc/pihole/setupVars.conf @@ -82,6 +82,18 @@ SetDNSServers(){ echo "server=${args[2]}" >> /etc/dnsmasq.d/01-pihole.conf echo "server=${args[3]}" >> /etc/dnsmasq.d/01-pihole.conf + # Remove domain-needed entry + sed -i '/domain-needed/d;' /etc/dnsmasq.d/01-pihole.conf + + # Readd it if required + if [[ "${args[4]}" == "domain-needed" ]]; then + echo "domain-needed" >> /etc/dnsmasq.d/01-pihole.conf + echo "DNS_FQDN_REQUIRED=true" >> /etc/pihole/setupVars.conf + else + echo "DNS_FQDN_REQUIRED=false" >> /etc/pihole/setupVars.conf + fi + # Leave it deleted if not wanted + # Restart dnsmasq to load new configuration RestartDNS From 2977168da139d0f547d898fa7baba181a653fef8 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 14 Dec 2016 16:16:25 +0100 Subject: [PATCH 4/4] dnsmasq "bogus-priv" property --- advanced/Scripts/webpage.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 3309fc99..d07e5c94 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -90,9 +90,21 @@ SetDNSServers(){ echo "domain-needed" >> /etc/dnsmasq.d/01-pihole.conf echo "DNS_FQDN_REQUIRED=true" >> /etc/pihole/setupVars.conf else + # Leave it deleted if not wanted echo "DNS_FQDN_REQUIRED=false" >> /etc/pihole/setupVars.conf fi - # Leave it deleted if not wanted + + # Remove bogus-priv entry + sed -i '/bogus-priv/d;' /etc/dnsmasq.d/01-pihole.conf + + # Readd it if required + if [[ "${args[5]}" == "bogus-priv" ]]; then + echo "bogus-priv" >> /etc/dnsmasq.d/01-pihole.conf + echo "DNS_BOGUS_PRIV=true" >> /etc/pihole/setupVars.conf + else + # Leave it deleted if not wanted + echo "DNS_BOGUS_PRIV=false" >> /etc/pihole/setupVars.conf + fi # Restart dnsmasq to load new configuration RestartDNS