From 159b29b80b801ae0ab58bdd189a84858afd87ac5 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 15:56:32 -0700 Subject: [PATCH 01/25] Replace spaces with tabs to make indentation consistent within the file. --- gravity.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index f1e70a63..e2126693 100755 --- a/gravity.sh +++ b/gravity.sh @@ -80,11 +80,11 @@ find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; | tr -d '\ # Append blacklist entries if they exist if [[ -f $blacklist ]];then - numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) - echo "** Blacklisting $numberOf domain(s)..." - cat $blacklist >> $origin/$matter + numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) + echo "** Blacklisting $numberOf domain(s)..." + cat $blacklist >> $origin/$matter else - : + : fi function gravity_advanced() From 0ec6eab683c02254ca32331c8aeb532e54097ee7 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 16:04:54 -0700 Subject: [PATCH 02/25] Appending ".$justDomainsExtension" to $saveLocation variable. Every use of $saveLocation was adding this and making lines longer. --- gravity.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gravity.sh b/gravity.sh index e2126693..058e72e7 100755 --- a/gravity.sh +++ b/gravity.sh @@ -51,15 +51,15 @@ do domain=$(echo "${sources[$i]}" | cut -d'/' -f3) # Save the file as list.#.domain - saveLocation=$origin/"list"."$i"."$domain" + saveLocation=$origin/list.$i.$domain.$justDomainsExtension # Use a case statement to download lists that need special cURL commands to complete properly case "$domain" in - "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; + "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation "${sources[$i]}");; - "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; + "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation "${sources[$i]}");; - *) data=$(curl -s -z $saveLocation."$justDomainsExtension" -A "Mozilla/10.0" "${sources[$i]}");; + *) data=$(curl -s -z $saveLocation -A "Mozilla/10.0" "${sources[$i]}");; esac if [[ -n "$data" ]];then @@ -68,7 +68,7 @@ do # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth - echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' > $saveLocation."$justDomainsExtension" + echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' > $saveLocation else echo "Skipping $domain list because it does not have any new entries..." fi From d6d192cb0a1a2adc9f2be31388d4e47c2f196728 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 16:22:07 -0700 Subject: [PATCH 03/25] Use `url` variable to store `${sources[$i]}` value to improve readability. I also wanted to replace the for loop iterating over indices with something like: `for url in $sources[@]}` It made the use of `$i` in the save location more annoying though. --- gravity.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index 058e72e7..934581e8 100755 --- a/gravity.sh +++ b/gravity.sh @@ -47,19 +47,20 @@ fi # Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines for ((i = 0; i < "${#sources[@]}"; i++)) do + url=${sources[$i]} # Get just the domain from the URL - domain=$(echo "${sources[$i]}" | cut -d'/' -f3) + domain=$(echo "$url" | cut -d'/' -f3) # Save the file as list.#.domain saveLocation=$origin/list.$i.$domain.$justDomainsExtension # Use a case statement to download lists that need special cURL commands to complete properly case "$domain" in - "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation "${sources[$i]}");; + "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation $url);; - "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation "${sources[$i]}");; + "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation $url);; - *) data=$(curl -s -z $saveLocation -A "Mozilla/10.0" "${sources[$i]}");; + *) data=$(curl -s -z $saveLocation -A "Mozilla/10.0" $url);; esac if [[ -n "$data" ]];then From 1f29d01694a293685feacd7abb4a2639e5cbcc6f Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 17:05:19 -0700 Subject: [PATCH 04/25] Remove leading and trailing whitespace and `.` characters and duplicate `.` characters as each list is stored. Should fix #32. --- gravity.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 934581e8..3dc9b8df 100755 --- a/gravity.sh +++ b/gravity.sh @@ -69,7 +69,8 @@ do # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth - echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' > $saveLocation + echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' | \ + sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' > $saveLocation else echo "Skipping $domain list because it does not have any new entries..." fi From bb7db1121465ede2909e3ee79244ad884a3cb372 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 17:33:30 -0700 Subject: [PATCH 05/25] Changing printouts when updating sources to tell what is going on when manually running gravity.sh This will print "Getting $domain list... " for each domain, followed by either "Done" if data was received and validated, or "Skipping list because it does not have any new entries" if no updates were needed. --- gravity.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 3dc9b8df..c6cd6b29 100755 --- a/gravity.sh +++ b/gravity.sh @@ -54,6 +54,7 @@ do # Save the file as list.#.domain saveLocation=$origin/list.$i.$domain.$justDomainsExtension + echo -n "Getting $domain list... " # Use a case statement to download lists that need special cURL commands to complete properly case "$domain" in "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation $url);; @@ -64,15 +65,15 @@ do esac if [[ -n "$data" ]];then - echo "Getting $domain list..." # Remove comments and print only the domain name # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' | \ sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' > $saveLocation + echo "Done." else - echo "Skipping $domain list because it does not have any new entries..." + echo "Skipping list because it does not have any new entries." fi done From e464c04490c4f3e336a26af09a9794ed1b9bd70a Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 17:47:22 -0700 Subject: [PATCH 06/25] Ignore domains in ad lists that do not contain `.` characters. This will skip entries such as `localhost`, `android`, `debian` and empty lines as listed in #35. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index c6cd6b29..40f87ccf 100755 --- a/gravity.sh +++ b/gravity.sh @@ -70,7 +70,7 @@ do # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' | \ - sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' > $saveLocation + sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' | grep "\." > $saveLocation echo "Done." else echo "Skipping list because it does not have any new entries." From a26377d2298fabb88aedd331b0fcabfac8066ef6 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 21:44:41 -0700 Subject: [PATCH 07/25] Append ad list sources to latentWhitelist.txt to prevent them from being filtered. Additional fixes for #35. This will prevent our own sources from being filtered out by competing source lists. --- gravity.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gravity.sh b/gravity.sh index 40f87ccf..8a6f22da 100755 --- a/gravity.sh +++ b/gravity.sh @@ -113,13 +113,21 @@ function gravity_advanced() if [[ -f $whitelist ]];then # Remove whitelist entries numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) - echo "** Whitelisting $numberOf domain(s)..." + plural=; [[ "$numberOf" != "1" ]] && plural=s + echo "** Whitelisting $numberOf domain${plural}..." # Append a "$" to the end of each line so it can be parsed out with grep -w - echo -n "^$" > $latentWhitelist awk -F '[# \t]' 'NF>0&&$1!="" {print $1"$"}' $whitelist > $latentWhitelist - cat $origin/$matter | grep -vwf $latentWhitelist > $origin/$andLight - gravity_advanced else - cat $origin/$matter > $origin/$andLight - gravity_advanced + rm $latentWhitelist fi + +# Prevent our sources from being pulled into the hole +plural=; [[ "${#sources[@]}" != "1" ]] && plural=s +echo "** Whitelisting ${#sources[@]} ad list source${plural}..." +for url in ${sources[@]} +do + echo "$url" | awk -F '/' '{print $3"$"}' >> $latentWhitelist +done +grep -vwf $latentWhitelist $origin/$matter > $origin/$andLight + +gravity_advanced From 98c94912e185babc6ba6e949c5fa1f30b5a2c1d2 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 23:37:01 -0700 Subject: [PATCH 08/25] Replace use of grep -w with grep -x. Prepend "^" to start of latentWhitelist.txt lines. The -x switch requires a full line match of the regexp, where as -w will try to find the match somewhere in the line, looking for work breaks. Combined with turning the whitelist lines into full regexps, this results in significantly faster parsing. Having "^" prepended to the lines also keeps false whitelisting from occuring, such as the following example: If whitelist.txt contains "google.com" it would whitelist many other sites that end in "google.com" as long as there is a non-word character preceeding the google (such as "-", or "."). --- gravity.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index 8a6f22da..9bad747d 100755 --- a/gravity.sh +++ b/gravity.sh @@ -115,8 +115,10 @@ if [[ -f $whitelist ]];then numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo "** Whitelisting $numberOf domain${plural}..." - # Append a "$" to the end of each line so it can be parsed out with grep -w - awk -F '[# \t]' 'NF>0&&$1!="" {print $1"$"}' $whitelist > $latentWhitelist + # Append a "$" to the end, prepend a "^" to the beginning, and + # replace "." with "\." of each line to turn each entry into a + # regexp so it can be parsed out with grep -x + awk -F '[# \t]' 'NF>0&&$1!="" {print "^"$1"$"}' $whitelist | sed 's/\./\\./g' > $latentWhitelist else rm $latentWhitelist fi @@ -126,8 +128,9 @@ plural=; [[ "${#sources[@]}" != "1" ]] && plural=s echo "** Whitelisting ${#sources[@]} ad list source${plural}..." for url in ${sources[@]} do - echo "$url" | awk -F '/' '{print $3"$"}' >> $latentWhitelist + echo "$url" | awk -F '/' '{print "^"$3"$"}' | sed 's/\./\\./g' >> $latentWhitelist done -grep -vwf $latentWhitelist $origin/$matter > $origin/$andLight + +grep -vxf $latentWhitelist $origin/$matter > $origin/$andLight gravity_advanced From 23713d82a0b96874811e23fc3e7f7bb01409969b Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sun, 6 Sep 2015 10:16:11 -0500 Subject: [PATCH 09/25] 1.6 million instead of 900,000 Updating to reflect the latest amount of domains the Pi-hole blocks. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3e5e9253..be0d4369 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ A more detailed explanation of the installation can be found [here](http://jacob [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") ## Gravity -The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 900,000 entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). +The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). ## Whitelist and blacklist You can add a `whitelist.txt` or `blacklist.txt` in `/etc/pihole/` and the script will apply those files automatically. @@ -47,4 +47,4 @@ A technical and detailed description can be found [here](http://jacobsalmela.com ## Other Operating Systems This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated. -[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") \ No newline at end of file +[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") From 4a4db7ab5607c33b84e55e1b67ae97da93e225e5 Mon Sep 17 00:00:00 2001 From: Jesse Becker Date: Fri, 11 Sep 2015 22:54:37 -0400 Subject: [PATCH 10/25] Allow for local settings to disable swap --- gravity.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index 2bef29b7..c7505b9b 100755 --- a/gravity.sh +++ b/gravity.sh @@ -19,9 +19,6 @@ sources=('https://adaway.org/hosts.txt' adList=/etc/pihole/gravity.list origin=/etc/pihole piholeDir=/etc/pihole -if [[ -f $piholeDir/pihole.conf ]];then - . $piholeDir/pihole.conf -fi justDomainsExtension=domains matter=pihole.0.matter.txt andLight=pihole.1.andLight.txt @@ -34,6 +31,13 @@ latentBlacklist=$origin/latentBlacklist.txt whitelist=$piholeDir/whitelist.txt latentWhitelist=$origin/latentWhitelist.txt +# After setting defaults, check if there's local overrides +if [[ -r $piholeDir/pihole.conf ]];then + echo "** Local calibration requested..." + . $piholeDir/pihole.conf +fi + + echo "** Neutrino emissions detected..." # Create the pihole resource directory if it doesn't exist. Future files will be stored here @@ -55,7 +59,11 @@ function createSwapFile() sudo dphys-swapfile swapon } -if [[ -f /etc/dphys-swapfile ]];then + +if [[ -z "$noSwap" ]]; then + # if $noSwap is set, don't do anything + : +elif [[ -f /etc/dphys-swapfile ]];then swapSize=$(cat /etc/dphys-swapfile | grep -m1 CONF_SWAPSIZE | cut -d'=' -f2) if [[ $swapSize != 500 ]];then mv /etc/dphys-swapfile /etc/dphys-swapfile.orig From cfac2be334b34f636edaaa0ff5e85fa981ce5704 Mon Sep 17 00:00:00 2001 From: Jesse Becker Date: Sun, 13 Sep 2015 15:23:29 -0400 Subject: [PATCH 11/25] toggle test case for noswap --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index c7505b9b..1f5e3fb6 100755 --- a/gravity.sh +++ b/gravity.sh @@ -60,7 +60,7 @@ function createSwapFile() } -if [[ -z "$noSwap" ]]; then +if [[ -n "$noSwap" ]]; then # if $noSwap is set, don't do anything : elif [[ -f /etc/dphys-swapfile ]];then From 8718321727913feaf6adfa73e2709b6607a77880 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Fri, 18 Sep 2015 00:06:04 +0200 Subject: [PATCH 12/25] Update basic-install.sh --- automated install/basic-install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c745c502..cd85424f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -27,12 +27,12 @@ read if [[ -f /etc/dnsmasq.d/adList.conf ]];then echo "Original Pi-hole detected. Initiating sub space transport..." sudo mkdir -p /etc/pihole/original/ - mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d") - mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d") - mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d") - mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d") - mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d") - mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d") + sudo mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d") + sudo mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d") + sudo mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d") + sudo mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d") + sudo mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d") + sudo mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d") else : fi From d15a085dd0b068f5b8d45a37c6f451e2a35c41df Mon Sep 17 00:00:00 2001 From: mospaeda Date: Fri, 18 Sep 2015 00:20:50 +0200 Subject: [PATCH 13/25] Update basic-install.sh --- automated install/basic-install.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index cd85424f..028b3dfa 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -8,6 +8,8 @@ # # Or run the commands below in order +pihole_gitsource=https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/ + clear echo " _____ _ _ _ " echo " | __ (_) | | | | " @@ -59,14 +61,14 @@ echo "Backing up original config files and downloading Pi-hole ones..." sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig sudo mv /var/www/index.lighttpd.html /var/www/index.lighttpd.orig -sudo curl -o /etc/dnsmasq.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf" -sudo curl -o /etc/lighttpd/lighttpd.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf" +sudo curl -o /etc/dnsmasq.conf $pihole_gitsource./advanced/dnsmasq.conf +sudo curl -o /etc/lighttpd/lighttpd.conf $pihole_gitsource./advanced/lighttpd.conf sudo mkdir /var/www/pihole -sudo curl -o /var/www/pihole/index.html "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html" +sudo curl -o /var/www/pihole/index.html $pihole_gitsource./advanced/index.html echo "Locating the Pi-hole..." -sudo curl -o /usr/local/bin/gravity.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh" -sudo curl -o /usr/local/bin/chronometer.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh" +sudo curl -o /usr/local/bin/gravity.sh $pihole_gitsource./gravity.sh +sudo curl -o /usr/local/bin/chronometer.sh $pihole_gitsource./advanced/Scripts/chronometer.sh sudo chmod 755 /usr/local/bin/gravity.sh sudo chmod 755 /usr/local/bin/chronometer.sh From 2d91a7a3c47a60f0726c33ee12987a29132887c7 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Fri, 18 Sep 2015 00:22:21 +0200 Subject: [PATCH 14/25] Update basic-install.sh --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 028b3dfa..478a1abf 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -8,7 +8,7 @@ # # Or run the commands below in order -pihole_gitsource=https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/ +pihole_gitsource="https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/" clear echo " _____ _ _ _ " From 2b4500363b6c32601da2446e39d7b67e6d13546a Mon Sep 17 00:00:00 2001 From: mospaeda Date: Fri, 18 Sep 2015 00:31:17 +0200 Subject: [PATCH 15/25] Update basic-install.sh --- automated install/basic-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 478a1abf..f00a19af 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -8,7 +8,6 @@ # # Or run the commands below in order -pihole_gitsource="https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/" clear echo " _____ _ _ _ " @@ -26,6 +25,8 @@ echo " Press Enter when ready " echo " " read +pihole_gitsource="https://raw.githubusercontent.com/mospaeda/pi-hole/master/" + if [[ -f /etc/dnsmasq.d/adList.conf ]];then echo "Original Pi-hole detected. Initiating sub space transport..." sudo mkdir -p /etc/pihole/original/ From 6fc798ebe489c45bf6b9b4922c0744ce537e6cbf Mon Sep 17 00:00:00 2001 From: mospaeda Date: Fri, 18 Sep 2015 00:40:21 +0200 Subject: [PATCH 16/25] Update basic-install.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 f00a19af..6d4ddd16 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -23,6 +23,7 @@ echo "Set a static IP before running this!" echo " " echo " Press Enter when ready " echo " " +echo " totootototo" read pihole_gitsource="https://raw.githubusercontent.com/mospaeda/pi-hole/master/" From 885069d4406d53fcecee2b74e81808d4f4137752 Mon Sep 17 00:00:00 2001 From: Jofre Palau Date: Fri, 18 Sep 2015 23:06:29 +0200 Subject: [PATCH 17/25] Allow external IP as an input script parameter: ./gravity.sh 123.123.123.123 --- gravity.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 2bef29b7..c90501f0 100755 --- a/gravity.sh +++ b/gravity.sh @@ -3,7 +3,12 @@ # Compiles a list of ad-serving domains by downloading them from multiple sources # This script should only be run after you have a static IP address set on the Pi -piholeIP=$(hostname -I) +piholeIP="$1" + +if [[ "$piholeIP" == "" ]]; then + piholeIP=$(hostname -I) +fi + # Ad-list sources--one per line in single quotes sources=('https://adaway.org/hosts.txt' @@ -128,7 +133,7 @@ function gravity_advanced() echo "** $numberOf unique domains trapped in the event horizon." # Format domain list as "192.168.x.x domain.com" echo "** Formatting domains into a HOSTS file..." - cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP"'" $0}' > $origin/$accretionDisc + cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP "'" $0}' > $origin/$accretionDisc # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it sudo cp $origin/$accretionDisc $adList kill -HUP $(pidof dnsmasq) From 11fcfc4bf58a5701a733bd82c775bc9d28edaa68 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Tue, 22 Sep 2015 22:10:33 +0200 Subject: [PATCH 18/25] Update basic-install.sh --- automated install/basic-install.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6d4ddd16..559dde85 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -8,7 +8,6 @@ # # Or run the commands below in order - clear echo " _____ _ _ _ " echo " | __ (_) | | | | " @@ -23,20 +22,17 @@ echo "Set a static IP before running this!" echo " " echo " Press Enter when ready " echo " " -echo " totootototo" read -pihole_gitsource="https://raw.githubusercontent.com/mospaeda/pi-hole/master/" - if [[ -f /etc/dnsmasq.d/adList.conf ]];then echo "Original Pi-hole detected. Initiating sub space transport..." sudo mkdir -p /etc/pihole/original/ - sudo mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d") - sudo mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d") - sudo mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d") - sudo mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d") - sudo mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d") - sudo mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d") + mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d") + mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d") + mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d") + mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d") + mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d") + mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d") else : fi @@ -45,6 +41,9 @@ echo "Updating the Pi..." sudo apt-get update sudo apt-get -y upgrade +echo "Installing tools..." +sudo apt-get -y install bc + echo "Installing DNS..." sudo apt-get -y install dnsmasq sudo update-rc.d dnsmasq enable @@ -63,14 +62,14 @@ echo "Backing up original config files and downloading Pi-hole ones..." sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig sudo mv /var/www/index.lighttpd.html /var/www/index.lighttpd.orig -sudo curl -o /etc/dnsmasq.conf $pihole_gitsource./advanced/dnsmasq.conf -sudo curl -o /etc/lighttpd/lighttpd.conf $pihole_gitsource./advanced/lighttpd.conf +sudo curl -o /etc/dnsmasq.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf" +sudo curl -o /etc/lighttpd/lighttpd.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf" sudo mkdir /var/www/pihole -sudo curl -o /var/www/pihole/index.html $pihole_gitsource./advanced/index.html +sudo curl -o /var/www/pihole/index.html "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html" echo "Locating the Pi-hole..." -sudo curl -o /usr/local/bin/gravity.sh $pihole_gitsource./gravity.sh -sudo curl -o /usr/local/bin/chronometer.sh $pihole_gitsource./advanced/Scripts/chronometer.sh +sudo curl -o /usr/local/bin/gravity.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh" +sudo curl -o /usr/local/bin/chronometer.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh" sudo chmod 755 /usr/local/bin/gravity.sh sudo chmod 755 /usr/local/bin/chronometer.sh From 96bc557e21111cc0d9ea660e40e25b42fdcd1027 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Tue, 22 Sep 2015 22:11:30 +0200 Subject: [PATCH 19/25] Update basic-install.sh --- automated install/basic-install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 559dde85..bc9ed38d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -27,12 +27,12 @@ read if [[ -f /etc/dnsmasq.d/adList.conf ]];then echo "Original Pi-hole detected. Initiating sub space transport..." sudo mkdir -p /etc/pihole/original/ - mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d") - mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d") - mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d") - mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d") - mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d") - mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d") + sudo mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d") + sudo mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d") + sudo mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d") + sudo mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d") + sudo mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d") + sudo mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d") else : fi From 56d4b7b0f7f0895e0fc36671aa510126c54ee595 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Tue, 22 Sep 2015 22:13:16 +0200 Subject: [PATCH 20/25] Update basic-install.sh --- 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 bc9ed38d..e0888848 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -43,6 +43,8 @@ sudo apt-get -y upgrade echo "Installing tools..." sudo apt-get -y install bc +sudo apt-get -y install toilet + echo "Installing DNS..." sudo apt-get -y install dnsmasq From 7b49677d24b51f20af067975019581aa8501c482 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Tue, 22 Sep 2015 22:38:25 +0200 Subject: [PATCH 21/25] add install for bc and toilet tools these tools are needed later by chronometer.sh --- automated install/basic-install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index e0888848..9a82f0c2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -45,7 +45,6 @@ echo "Installing tools..." sudo apt-get -y install bc sudo apt-get -y install toilet - echo "Installing DNS..." sudo apt-get -y install dnsmasq sudo update-rc.d dnsmasq enable From 4ea397bc717b110c3e8c37889c27a7bf5fd6ee02 Mon Sep 17 00:00:00 2001 From: Jofre Palau Date: Mon, 28 Sep 2015 17:40:13 +0200 Subject: [PATCH 22/25] Removed extra blank space if no IP added --- gravity.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index c90501f0..30e8413e 100755 --- a/gravity.sh +++ b/gravity.sh @@ -5,8 +5,8 @@ # This script should only be run after you have a static IP address set on the Pi piholeIP="$1" -if [[ "$piholeIP" == "" ]]; then - piholeIP=$(hostname -I) +if [ -n "$piholeIP"]; then + piholeIP=$(hostname -I|xargs) fi @@ -133,7 +133,7 @@ function gravity_advanced() echo "** $numberOf unique domains trapped in the event horizon." # Format domain list as "192.168.x.x domain.com" echo "** Formatting domains into a HOSTS file..." - cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP "'" $0}' > $origin/$accretionDisc + cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP "'" $0}' > $origin/$accretionDisc # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it sudo cp $origin/$accretionDisc $adList kill -HUP $(pidof dnsmasq) From d52fdde2f8462ebca8f79610f7ee4fb2ae12342d Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sat, 3 Oct 2015 11:06:50 -0500 Subject: [PATCH 23/25] using double bracket notation Despite the script running successfully, it produced this error: `/usr/local/bin/gravity.sh: line 8: [: missing `]'` prior to this fix. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index ba1ac671..d548d13e 100755 --- a/gravity.sh +++ b/gravity.sh @@ -5,7 +5,7 @@ # This script should only be run after you have a static IP address set on the Pi piholeIP="$1" -if [ -n "$piholeIP"]; then +if [[ -n "$piholeIP" ]]; then piholeIP=$(hostname -I|xargs) fi From 06e89614e99a0e4ddf20b47f481c20c5a3dc391f Mon Sep 17 00:00:00 2001 From: mospaeda Date: Mon, 5 Oct 2015 23:58:15 +0200 Subject: [PATCH 24/25] Dnsutils package missing for dig tool --- 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 9a82f0c2..80bb7543 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -42,6 +42,7 @@ sudo apt-get update sudo apt-get -y upgrade echo "Installing tools..." +sudo apt-get -y install dnsutils sudo apt-get -y install bc sudo apt-get -y install toilet From 6976532ef5b52f3b0c769e35b3071c5decdbb9aa Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Tue, 6 Oct 2015 06:12:52 -0500 Subject: [PATCH 25/25] Removing IP as input Due to users having issues with the IP not being entered properly, I am restoring the original way to store `piholeIP` until a better solution can be formed. --- gravity.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/gravity.sh b/gravity.sh index d548d13e..1f5e3fb6 100755 --- a/gravity.sh +++ b/gravity.sh @@ -3,12 +3,7 @@ # Compiles a list of ad-serving domains by downloading them from multiple sources # This script should only be run after you have a static IP address set on the Pi -piholeIP="$1" - -if [[ -n "$piholeIP" ]]; then - piholeIP=$(hostname -I|xargs) -fi - +piholeIP=$(hostname -I) # Ad-list sources--one per line in single quotes sources=('https://adaway.org/hosts.txt' @@ -141,7 +136,7 @@ function gravity_advanced() echo "** $numberOf unique domains trapped in the event horizon." # Format domain list as "192.168.x.x domain.com" echo "** Formatting domains into a HOSTS file..." - cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP "'" $0}' > $origin/$accretionDisc + cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP"'" $0}' > $origin/$accretionDisc # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it sudo cp $origin/$accretionDisc $adList kill -HUP $(pidof dnsmasq)