From 0add5eb2919386f546a75be4b6c1e5f4f13a537a Mon Sep 17 00:00:00 2001 From: Matthias Rank Date: Tue, 12 May 2020 21:02:29 +0200 Subject: [PATCH 1/2] Added support for CNAME record add/remvoe Signed-off-by: Matthias Rank --- advanced/Scripts/webpage.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index f0f8bc31..2a32879b 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -18,6 +18,7 @@ readonly FTLconf="/etc/pihole/pihole-FTL.conf" readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf" readonly PI_HOLE_BIN_DIR="/usr/local/bin" readonly dnscustomfile="/etc/pihole/custom.list" +readonly dnscustomcnamefile="/etc/dnsmasq.d/05-pihole-custom-cname.conf" readonly gravityDBfile="/etc/pihole/gravity.db" @@ -644,6 +645,28 @@ RemoveCustomDNSAddress() { RestartDNS } +AddCustomCNAMERecord() { + echo -e " ${TICK} Adding custom CNAME record..." + + domain="${args[2]}" + target="${args[3]}" + echo "cname=${domain},${target}" >> "${dnscustomcnamefile}" + + # Restart dnsmasq to load new custom CNAME records + RestartDNS +} + +RemoveCustomCNAMERecord() { + echo -e " ${TICK} Removing custom CNAME record..." + + domain="${args[2]}" + target="${args[3]}" + sed -i "/cname=${domain},${target}/d" "${dnscustomcnamefile}" + + # Restart dnsmasq to update removed custom CNAME records + RestartDNS +} + main() { args=("$@") @@ -677,6 +700,8 @@ main() { "-l" | "privacylevel" ) SetPrivacyLevel;; "addcustomdns" ) AddCustomDNSAddress;; "removecustomdns" ) RemoveCustomDNSAddress;; + "addcustomcname" ) AddCustomCNAMERecord;; + "removecustomcname" ) RemoveCustomCNAMERecord;; * ) helpFunc;; esac From 2b9898e9ca79ad367953cd4d366a27bbaae5004b Mon Sep 17 00:00:00 2001 From: Matthias Rank Date: Tue, 12 May 2020 21:04:30 +0200 Subject: [PATCH 2/2] Fixed indentation Signed-off-by: Matthias Rank --- advanced/Scripts/webpage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 2a32879b..67251a8d 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -650,7 +650,7 @@ AddCustomCNAMERecord() { domain="${args[2]}" target="${args[3]}" - echo "cname=${domain},${target}" >> "${dnscustomcnamefile}" + echo "cname=${domain},${target}" >> "${dnscustomcnamefile}" # Restart dnsmasq to load new custom CNAME records RestartDNS