From 4301b9a12a472f0e82ac64c421793ffa7145abf3 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 25 Jan 2017 10:33:25 +0100 Subject: [PATCH] Add static DHCP leases to new file --- advanced/Scripts/webpage.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 02610d85..10d53045 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -12,6 +12,8 @@ readonly setupVars="/etc/pihole/setupVars.conf" readonly dnsmasqconfig="/etc/dnsmasq.d/01-pihole.conf" readonly dhcpconfig="/etc/dnsmasq.d/02-pihole-dhcp.conf" +# 03 -> wildcards +readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf" helpFunc() { cat << EOM @@ -313,6 +315,24 @@ ResolutionSettings() { fi } +AddDHCPStaticAddress() { + + mac="${args[2]}" + ip="${args[3]}" + host="${args[4]}" + + if [[ "${ip}" == "noip" ]]; then + # Static host name + echo "dhcp-host=${mac},${host}" >> "dhcpstaticconfig" + elif [[ "${host}" == "nohost" ]]; then + # Static IP + echo "dhcp-host=${mac},${ip}" >> "dhcpstaticconfig" + else + # Full info given + echo "dhcp-host=${mac},${ip},${host}" >> "dhcpstaticconfig" + fi +} + main() { args=("$@") @@ -334,6 +354,7 @@ main() { "-h" | "--help" ) helpFunc;; "privacymode" ) SetPrivacyMode;; "resolve" ) ResolutionSettings;; + "addstatic" ) AddDHCPStaticAddress;; * ) helpFunc;; esac