From 4c853defb25d9e51b82ed8aa9fdbf9d9834dea2d Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 25 Oct 2016 22:27:35 +0100 Subject: [PATCH 1/6] add if traps to check for existence of whitelist.txt / blacklist.txt --- gravity.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/gravity.sh b/gravity.sh index 03aafabb..f524e587 100755 --- a/gravity.sh +++ b/gravity.sh @@ -187,12 +187,16 @@ gravity_Schwarzchild() { gravity_Blacklist() { # Append blacklist entries if they exist - numBlacklisted=$(wc -l < "${blacklistFile}") - plural=; [[ "$numBlacklisted" != "1" ]] && plural=s + if [[ -f "${blacklistFile}" ]]; then + numBlacklisted=$(wc -l < "${blacklistFile}") + plural=; [[ "$numBlacklisted" != "1" ]] && plural=s + echo -n "::: BlackListing $numBlacklisted domain${plural}..." + cat ${blacklistFile} >> ${piholeDir}/${eventHorizon} + echo " done!" + else + echo "::: Nothing to blacklist!" + fi - echo -n "::: BlackListing $numBlacklisted domain${plural}..." - cat ${blacklistFile} >> ${piholeDir}/${eventHorizon} - echo " done!" } gravity_Whitelist() { @@ -209,15 +213,19 @@ gravity_Whitelist() { done echo " done!" - # Ensure adlist domains are in whitelist.txt + # Ensure adlist domains are in whitelist.txt ${whitelistScript} -nr -q "${urls[@]}" > /dev/null - # Remove anything in whitelist.txt from the Event Horizon - numWhitelisted=$(wc -l < "${whitelistFile}") - plural=; [[ "$numWhitelisted" != "1" ]] && plural=s - echo -n "::: Whitelisting $numWhitelisted domain${plural}..." - grep -F -x -v -f ${whitelistFile} ${piholeDir}/${preEventHorizon} > ${piholeDir}/${eventHorizon} - echo " done!" + 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}..." + grep -F -x -v -f ${whitelistFile} ${piholeDir}/${preEventHorizon} > ${piholeDir}/${eventHorizon} + echo " done!" + else + echo "::: Nothing to whitelist!" + fi } gravity_unique() { From fc776921d5e19f5bfd71e2d88adc8b2977867508 Mon Sep 17 00:00:00 2001 From: Eric Warnke Date: Wed, 26 Oct 2016 09:59:22 -0400 Subject: [PATCH 2/6] stty is more compatible and does not require any additional dependancies for busybox --- 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 dfed93a1..2f55e1b0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -33,8 +33,8 @@ IPv4_address="" IPv6_address="" # Find the rows and columns -rows=$(tput lines) -columns=$(tput cols) +rows=$(stty size | awk '{print $1}') +columns=$(stty size | awk '{print $2}') # Divide by two so the dialogs take up half of the screen, which looks nice. r=$(( rows / 2 )) From ac8d24a1cea3a09877d97299e24adb2d8ec0cbd7 Mon Sep 17 00:00:00 2001 From: Eric Warnke Date: Wed, 26 Oct 2016 10:08:23 -0400 Subject: [PATCH 3/6] Even with no detected screen size, it should presume 80x24 --- automated install/basic-install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 2f55e1b0..7af51c5b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -32,9 +32,10 @@ useUpdateVars=false IPv4_address="" IPv6_address="" -# Find the rows and columns -rows=$(stty size | awk '{print $1}') -columns=$(stty size | awk '{print $2}') +# Find the rows and columns will default to 80x24 is it can not be detected +screen_size=$(stty size 2>/dev/null || echo 24 80) +rows=$(echo $screen_size | awk '{print $1}') +columns=$(echo $screen_size | awk '{print $2}') # Divide by two so the dialogs take up half of the screen, which looks nice. r=$(( rows / 2 )) From 4ed6e4d016d9c0aead21edb92cada243d248bd49 Mon Sep 17 00:00:00 2001 From: Eric Warnke Date: Wed, 26 Oct 2016 10:44:15 -0400 Subject: [PATCH 4/6] Tiny screens get sane minimums --- automated install/basic-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 7af51c5b..ae3a4529 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -40,6 +40,9 @@ columns=$(echo $screen_size | awk '{print $2}') # Divide by two so the dialogs take up half of the screen, which looks nice. r=$(( rows / 2 )) c=$(( columns / 2 )) +# Unless the screen is tiny +r=$(( r < 20 ? 20 : r )) +c=$(( c < 70 ? 70 : c )) ######## Undocumented Flags. Shhh ######## skipSpaceCheck=false From e2997b81352e9a68a46187c109df7c7f5360ad93 Mon Sep 17 00:00:00 2001 From: Eric Warnke Date: Tue, 25 Oct 2016 14:46:26 -0400 Subject: [PATCH 5/6] Due to lighttpd bug 2526 the url.rewrite for javascript must be placed outside of the $HTTP block or it will never evaluate. --- advanced/lighttpd.conf.debian | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/advanced/lighttpd.conf.debian b/advanced/lighttpd.conf.debian index 8b62f448..bf2e5104 100644 --- a/advanced/lighttpd.conf.debian +++ b/advanced/lighttpd.conf.debian @@ -52,10 +52,11 @@ $HTTP["url"] =~ "^/admin/" { ) } +# Rewite js requests, must be out of $HTTP block due to bug #2526 +url.rewrite = ( "^(?!/admin/).*\.js$" => "pihole/index.js" ) + # If the URL does not start with /admin, then it is a query for an ad domain $HTTP["url"] =~ "^(?!/admin)/.*" { # Create a response header for debugging using curl -I setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." ) - # rewrite only js requests - url.rewrite = ("(.*).js" => "pihole/index.js") } From f1c1caf7bdac56e4ae22d600cad9f5e70bbeac80 Mon Sep 17 00:00:00 2001 From: Eric Warnke Date: Tue, 25 Oct 2016 14:48:32 -0400 Subject: [PATCH 6/6] url.rewrite does not work in $HTTP block lighttpd bug #2526 --- advanced/lighttpd.conf.fedora | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/advanced/lighttpd.conf.fedora b/advanced/lighttpd.conf.fedora index 8b8e0692..fc00923c 100644 --- a/advanced/lighttpd.conf.fedora +++ b/advanced/lighttpd.conf.fedora @@ -69,10 +69,11 @@ $HTTP["url"] =~ "^/admin/" { setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" ) } +# Rewite js requests, must be out of $HTTP block due to bug #2526 +url.rewrite = ( "^(?!/admin/).*\.js$" => "pihole/index.js" ) + # If the URL does not start with /admin, then it is a query for an ad domain $HTTP["url"] =~ "^(?!/admin)/.*" { # Create a response header for debugging using curl -I setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." ) - # rewrite only js requests - url.rewrite = ("(.*).js" => "pihole/index.js") }