From 47cba8345080894fd494f99cea3e69bda08d27bd Mon Sep 17 00:00:00 2001 From: Steve Dobinson Date: Tue, 20 Sep 2016 10:34:21 +0100 Subject: [PATCH 01/17] Update lighttpd.conf.debian Allow for password protection (or other user-initiated options) without clobbering already chosen user options. --- advanced/lighttpd.conf.debian | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/advanced/lighttpd.conf.debian b/advanced/lighttpd.conf.debian index 8b62f448..81f1b765 100644 --- a/advanced/lighttpd.conf.debian +++ b/advanced/lighttpd.conf.debian @@ -12,6 +12,7 @@ server.modules = ( "mod_access", "mod_accesslog", + "mod_auth", "mod_expire", "mod_compress", "mod_redirect", @@ -59,3 +60,6 @@ $HTTP["url"] =~ "^(?!/admin)/.*" { # rewrite only js requests url.rewrite = ("(.*).js" => "pihole/index.js") } + +# Add user chosen options held in external file +include_shell "cat external.conf 2>/dev/null" From 737b510116d673dd2799a40a4365ca626867223d Mon Sep 17 00:00:00 2001 From: Steve Dobinson Date: Tue, 20 Sep 2016 10:38:58 +0100 Subject: [PATCH 02/17] Update lighttpd.conf.fedora Allow for password protection (or other user-initiated options) without clobbering already chosen user options. --- advanced/lighttpd.conf.fedora | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/advanced/lighttpd.conf.fedora b/advanced/lighttpd.conf.fedora index 30784b1a..3719d502 100644 --- a/advanced/lighttpd.conf.fedora +++ b/advanced/lighttpd.conf.fedora @@ -11,6 +11,7 @@ server.modules = ( "mod_access", + "mod_auth", "mod_fastcgi", "mod_accesslog", "mod_expire", @@ -75,3 +76,6 @@ $HTTP["url"] =~ "^(?!/admin)/.*" { # rewrite only js requests url.rewrite = ("(.*).js" => "pihole/index.js") } + +# Add user chosen options held in external file +include_shell "cat external.conf 2>/dev/null" From 8872594ab9069216c77e843d9f7f7f445b50a7ed Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 19 Oct 2016 14:27:17 +0200 Subject: [PATCH 03/17] create upload dir for lighttpd directory is missing in the installation process but is used in the lighttpd.conf --- automated install/basic-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 8072f79a..fa0af816 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -583,6 +583,8 @@ installConfigs() { chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd mkdir -p /var/cache/lighttpd/compress chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress + mkdir -p /var/cache/lighttpd/uploads + chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/uploads } stop_service() { From eb52f81a5c3412a231bb6fa3ffd7b17ef8f0e8e3 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 25 Oct 2016 14:54:10 +0100 Subject: [PATCH 04/17] 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 05/17] 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 06/17] 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 07/17] 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 08/17] 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 09/17] 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 10/17] 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 11/17] 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 60142cd960cecd6abac329243aa9e6c85b86521d Mon Sep 17 00:00:00 2001 From: Promofaux Date: Thu, 27 Oct 2016 11:06:11 +0100 Subject: [PATCH 12/17] remove reference to whitelist.sh (no longer exists) replace with `pihole -w` --- gravity.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index f524e587..1e4a3a93 100755 --- a/gravity.sh +++ b/gravity.sh @@ -29,8 +29,7 @@ EOM adListFile=/etc/pihole/adlists.list adListDefault=/etc/pihole/adlists.default -whitelistScript=/opt/pihole/whitelist.sh -blacklistScript=/opt/pihole/blacklist.sh +whitelistScript="pihole -w" whitelistFile=/etc/pihole/whitelist.txt blacklistFile=/etc/pihole/blacklist.txt From 9e4e1d1cb2d7b8a1293e510289a6c91581cf2985 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Thu, 27 Oct 2016 11:09:24 +0100 Subject: [PATCH 13/17] improve comments --- gravity.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 1e4a3a93..8373b4aa 100755 --- a/gravity.sh +++ b/gravity.sh @@ -185,7 +185,7 @@ gravity_Schwarzchild() { } gravity_Blacklist() { - # Append blacklist entries if they exist + # Append blacklist entries to eventHorizon if they exist if [[ -f "${blacklistFile}" ]]; then numBlacklisted=$(wc -l < "${blacklistFile}") plural=; [[ "$numBlacklisted" != "1" ]] && plural=s @@ -215,11 +215,13 @@ gravity_Whitelist() { # Ensure adlist domains are in whitelist.txt ${whitelistScript} -nr -q "${urls[@]}" > /dev/null + # Check whitelist.txt exists. if [[ -f "${whitelistFile}" ]]; then # Remove anything in whitelist.txt from the Event Horizon numWhitelisted=$(wc -l < "${whitelistFile}") plural=; [[ "$numWhitelisted" != "1" ]] && plural=s echo -n "::: Whitelisting $numWhitelisted domain${plural}..." + #print everything from preEventHorizon into eventHorizon EXCEPT domains in whitelist.txt grep -F -x -v -f ${whitelistFile} ${piholeDir}/${preEventHorizon} > ${piholeDir}/${eventHorizon} echo " done!" else From cde003bc98c965c1fba15cde9498a46311df5301 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Thu, 27 Oct 2016 11:13:00 +0100 Subject: [PATCH 14/17] \ 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} From 794fa211372a4b6daa5e311d4454277abe229d57 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Thu, 27 Oct 2016 12:44:21 +0100 Subject: [PATCH 15/17] install uninstall.sh... --- automated install/basic-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 620ac17f..89191fed 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -565,6 +565,7 @@ installScripts() { install -o "${USER}" -Dm755 -t /opt/pihole/ gravity.sh install -o "${USER}" -Dm755 -t /opt/pihole/ ./advanced/Scripts/*.sh + install -o "${USER}" -Dm755 -t /opt/pihole/ ./automated\ install/uninstall.sh install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole From 300001e766b85ac67b847f213079a79fb2c7478d Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 27 Oct 2016 11:56:16 -0700 Subject: [PATCH 16/17] Remove `listen-address` directive Since we declare an `interface` `dnsmasq` should ignore the `listen-address` directive thus making redundant. Removed. --- advanced/01-pihole.conf | 2 -- 1 file changed, 2 deletions(-) diff --git a/advanced/01-pihole.conf b/advanced/01-pihole.conf index 7ec37e3f..f4707ef4 100644 --- a/advanced/01-pihole.conf +++ b/advanced/01-pihole.conf @@ -39,8 +39,6 @@ server=@DNS2@ interface=@INT@ -listen-address=127.0.0.1 - cache-size=10000 log-queries From 6a4a468022515797bfdca924a8bc51547703aeff Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 28 Oct 2016 15:02:03 +0100 Subject: [PATCH 17/17] Create .codeclimate.yml --- .codeclimate.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .codeclimate.yml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 00000000..e1cb3b50 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,3 @@ +engines: + shellcheck: + enabled: true