From eb52f81a5c3412a231bb6fa3ffd7b17ef8f0e8e3 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 25 Oct 2016 14:54:10 +0100 Subject: [PATCH 1/9] add pi.hole entries to 01-pihole.conf --- advanced/01-pihole.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/advanced/01-pihole.conf b/advanced/01-pihole.conf index fd8e27f2..02fc786a 100644 --- a/advanced/01-pihole.conf +++ b/advanced/01-pihole.conf @@ -20,6 +20,9 @@ # OR IN /etc/dnsmasq.conf # ############################################################################### +address=/pi.hole/@IPv4@ +address=/pi.hole/@IPv6@ + addn-hosts=/etc/pihole/gravity.list domain-needed From 911053f63f341b38dc484ba60a5943167b87528b Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 25 Oct 2016 15:00:18 +0100 Subject: [PATCH 2/9] Replace IPv4 and IPv6 tokens in 01-pihole.conf for pi.hole resolution. --- automated install/basic-install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index dfed93a1..72e893b0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -536,6 +536,11 @@ version_check_dnsmasq() { else sed -i '/^server=@DNS2@/d' ${dnsmasq_pihole_01_location} fi + #Replace IPv4 and IPv6 tokens in 01-pihole.conf for pi.hole resolution. + tmp = ${IPv4_address%/*} + sed -i "s/@IPv4@/$tmp/" ${dnsmasq_pihole_01_location} + sed -i "s/@IPv6@/$IPv6_address/" ${dnsmasq_pihole_01_location} + sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsmasq_conf} } From 7653b3d08831ada4f951ff1efc284e11ce387cc8 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 25 Oct 2016 15:01:16 +0100 Subject: [PATCH 3/9] Remove pi.hole references in gravity.sh --- gravity.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index 03aafabb..b4a512c6 100755 --- a/gravity.sh +++ b/gravity.sh @@ -244,19 +244,19 @@ gravity_hostFormat() { if [[ -n "${IPv4_address}" && -n "${IPv6_address}" ]];then # Both IPv4 and IPv6 - echo -e "$IPv4_address $hostname\n$IPv6_address $hostname\n$IPv4_address pi.hole\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc} + echo -e "$IPv4_address $hostname\n$IPv6_address $hostname" > ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4_address" -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc} elif [[ -n "${IPv4_address}" && -z "${IPv6_address}" ]];then # Only IPv4 - echo -e "$IPv4_address $hostname\n$IPv4_address pi.hole" > ${piholeDir}/${accretionDisc} + echo -e "$IPv4_address $hostname" > ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4_address" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc} elif [[ -z "${IPv4_address}" && -n "${IPv6_address}" ]];then # Only IPv6 - echo -e "$IPv6_address $hostname\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc} + echo -e "$IPv6_address $hostname" > ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc} elif [[ -z "${IPv4_address}" && -z "${IPv6_address}" ]];then From 18005ceee821b177426f95e24a53a096549f0f68 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 25 Oct 2016 15:03:49 +0100 Subject: [PATCH 4/9] add hostname lines in 01-pihole.conf --- advanced/01-pihole.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/advanced/01-pihole.conf b/advanced/01-pihole.conf index 02fc786a..7ec37e3f 100644 --- a/advanced/01-pihole.conf +++ b/advanced/01-pihole.conf @@ -23,6 +23,9 @@ address=/pi.hole/@IPv4@ address=/pi.hole/@IPv6@ +address=/@HOSTNAME@/@IPv4@ +address=/@HOSTNAME@/@IPv6@ + addn-hosts=/etc/pihole/gravity.list domain-needed From 86349527e7c509f0152fc5370d27b2edd08c86dd Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 25 Oct 2016 15:06:37 +0100 Subject: [PATCH 5/9] replace HOSTNAME tokens in 01-pihole.conf --- automated install/basic-install.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 72e893b0..0bc43b49 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -536,6 +536,18 @@ version_check_dnsmasq() { else sed -i '/^server=@DNS2@/d' ${dnsmasq_pihole_01_location} fi + + if [[ -f /etc/hostname ]]; then + hostname=$( Date: Tue, 25 Oct 2016 15:07:29 +0100 Subject: [PATCH 6/9] remove hostname insertion into gravity.list from gravity.sh --- gravity.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/gravity.sh b/gravity.sh index b4a512c6..3268020e 100755 --- a/gravity.sh +++ b/gravity.sh @@ -232,31 +232,20 @@ gravity_unique() { gravity_hostFormat() { # Format domain list as "192.168.x.x domain.com" echo "::: Formatting domains into a HOSTS file..." - if [[ -f /etc/hostname ]]; then - hostname=$( ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4_address" -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc} elif [[ -n "${IPv4_address}" && -z "${IPv6_address}" ]];then # Only IPv4 - echo -e "$IPv4_address $hostname" > ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4_address" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc} elif [[ -z "${IPv4_address}" && -n "${IPv6_address}" ]];then # Only IPv6 - echo -e "$IPv6_address $hostname" > ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc} elif [[ -z "${IPv4_address}" && -z "${IPv6_address}" ]];then From 95f0b3710dea79da87856f724684c34106df8ee2 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 25 Oct 2016 15:27:13 +0100 Subject: [PATCH 7/9] fix up logic --- automated install/basic-install.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 0bc43b49..b03aaff7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -537,21 +537,35 @@ version_check_dnsmasq() { sed -i '/^server=@DNS2@/d' ${dnsmasq_pihole_01_location} fi + #sed -i "s/@HOSTNAME@/$hostname/" ${dnsmasq_pihole_01_location} + if [[ -f /etc/hostname ]]; then hostname=$( Date: Tue, 25 Oct 2016 15:29:02 +0100 Subject: [PATCH 8/9] actually fix up logic --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index b03aaff7..0f36a722 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -547,7 +547,7 @@ version_check_dnsmasq() { #Replace IPv4 and IPv6 tokens in 01-pihole.conf for pi.hole resolution. if [[ "${IPv4_address}" != "" ]]; then - tmp = ${IPv4_address%/*} + tmp=${IPv4_address%/*} sed -i "s/@IPv4@/$tmp/" ${dnsmasq_pihole_01_location} else sed -i '/^address=/pi.hole/@IPv4@/d' ${dnsmasq_pihole_01_location} @@ -555,7 +555,7 @@ version_check_dnsmasq() { fi if [[ "${IPv6_address}" != "" ]]; then - sed -i "s/@IPv4@/$IPv6_address/" ${dnsmasq_pihole_01_location} + sed -i "s/@IPv6@/$IPv6_address/" ${dnsmasq_pihole_01_location} else sed -i '/^address=/pi.hole/@IPv6@/d' ${dnsmasq_pihole_01_location} sed -i '/^address=/@HOSTNAME@/@IPv6@/d' ${dnsmasq_pihole_01_location} From cde003bc98c965c1fba15cde9498a46311df5301 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Thu, 27 Oct 2016 11:13:00 +0100 Subject: [PATCH 9/9] \ all the /s! --- automated install/basic-install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 0f36a722..6a305106 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -550,21 +550,21 @@ version_check_dnsmasq() { tmp=${IPv4_address%/*} sed -i "s/@IPv4@/$tmp/" ${dnsmasq_pihole_01_location} else - sed -i '/^address=/pi.hole/@IPv4@/d' ${dnsmasq_pihole_01_location} - sed -i '/^address=/@HOSTNAME@/@IPv4@/d' ${dnsmasq_pihole_01_location} + sed -i '/^address=\/pi.hole\/@IPv4@/d' ${dnsmasq_pihole_01_location} + sed -i '/^address=\/@HOSTNAME@\/@IPv4@/d' ${dnsmasq_pihole_01_location} fi if [[ "${IPv6_address}" != "" ]]; then sed -i "s/@IPv6@/$IPv6_address/" ${dnsmasq_pihole_01_location} else - sed -i '/^address=/pi.hole/@IPv6@/d' ${dnsmasq_pihole_01_location} - sed -i '/^address=/@HOSTNAME@/@IPv6@/d' ${dnsmasq_pihole_01_location} + sed -i '/^address=\/pi.hole\/@IPv6@/d' ${dnsmasq_pihole_01_location} + sed -i '/^address=\/@HOSTNAME@\/@IPv6@/d' ${dnsmasq_pihole_01_location} fi if [[ "${hostname}" != "" ]]; then sed -i "s/@HOSTNAME@/$hostname/" ${dnsmasq_pihole_01_location} else - sed -i '/^address=/@HOSTNAME@*/d' ${dnsmasq_pihole_01_location} + sed -i '/^address=\/@HOSTNAME@*/d' ${dnsmasq_pihole_01_location} fi sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsmasq_conf}