From 88d4108f920740e0408ccc4703330d3364b5b6fd Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 17 Apr 2018 09:50:25 +0100 Subject: [PATCH 1/4] - Add new whipstail to choose from example blocklists on new install - remove adlists.default - do not copy non-existent adlists.default on run of gravity Signed-off-by: Adam Warner --- adlists.default | 23 ------------------ automated install/basic-install.sh | 38 ++++++++++++++++++++++++++++++ gravity.sh | 6 +---- 3 files changed, 39 insertions(+), 28 deletions(-) delete mode 100644 adlists.default diff --git a/adlists.default b/adlists.default deleted file mode 100644 index cbc1bfb3..00000000 --- a/adlists.default +++ /dev/null @@ -1,23 +0,0 @@ -# The below list amalgamates several lists we used previously. -# See `https://github.com/StevenBlack/hosts` for details -##StevenBlack's list -https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts - -##MalwareDomains -https://mirror1.malwaredomains.com/files/justdomains - -##Cameleon -http://sysctl.org/cameleon/hosts - -##Zeustracker -https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist - -##Disconnect.me Tracking -https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt - -##Disconnect.me Ads -https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt - -##Hosts-file.net -https://hosts-file.net/ad_servers.txt - diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 160039ce..87e10751 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -49,6 +49,7 @@ PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update versi PI_HOLE_INSTALL_DIR="/opt/pihole" useUpdateVars=false +adlistFile="/etc/pihole/adlists.list" # Pi-hole needs an IP address; to begin, these variables are empty since we don't know what the IP is until # this script can run IPV4_ADDRESS="" @@ -955,6 +956,39 @@ setAdminFlag() { esac } +# A function to display a list of example blocklists for users to select +chooseBlocklists() { + # Let user select (or not) blocklists via a checklist + cmd=(whiptail --separate-output --checklist "In order to block ads Pi-Hole relies on blacklists, either sourced from third party curated lists, or through building up a custom blacklist.\\n\\nBelow you will find some examples of third party lists.\\n\\nPlease note, the installation can be completed without any of these lists selected, but nothing will be blocked until you add your own." "${r}" "${c}" 7) + # In an array, show the options available (all off by default): + options=(StevenBlack "StevenBlack's Unified Hosts List" off + MalwareDom "MalwareDomains" off + Cameleon "Cameleon" off + ZeusTracker "ZeusTracker" off + DisconTrack "Disconnect.me Tracking" off + DisconAd "Disconnect.me Ads" off + HostsFile "Hosts-file.net Ads" off) + + # In a variable, show the choices available; exit if Cancel is selected + choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) || { echo -e " ${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}"; exit 1; } + # For each choice available, + for choice in ${choices} + do + # Set the values to true + case ${choice} in + StevenBlack ) echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >> "${adlistFile}";; + MalwareDom ) echo "https://mirror1.malwaredomains.com/files/justdomains" >> "${adlistFile}";; + Cameleon ) echo "http://sysctl.org/cameleon/hosts" >> "${adlistFile}";; + ZeusTracker ) echo "https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist" >> "${adlistFile}";; + DisconTrack ) echo "https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt" >> "${adlistFile}";; + DisconAd ) echo "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt" >> "${adlistFile}";; + HostsFile ) echo "https://hosts-file.net/ad_servers.txt" >> "${adlistFile}";; + esac + done + + +} + # Check if /etc/dnsmasq.conf is from pi-hole. If so replace with an original and install new in .d directory version_check_dnsmasq() { # Local, named variables @@ -2100,6 +2134,10 @@ main() { chooseInterface # Decide what upstream DNS Servers to use setDNS + # If adlists.list file does not exist, give the user the choice of adding some example lists + if [[ ! -f "${adlistFile}" ]]; then + chooseBlocklists + fi # Let the user decide if they want to block ads over IPv4 and/or IPv6 use4andor6 # Let the user decide if they want the web interface to be installed automatically diff --git a/gravity.sh b/gravity.sh index 5806dea7..848fe574 100755 --- a/gravity.sh +++ b/gravity.sh @@ -20,11 +20,9 @@ basename="pihole" PIHOLE_COMMAND="/usr/local/bin/${basename}" piholeDir="/etc/${basename}" -piholeRepo="/etc/.${basename}" adListFile="${piholeDir}/adlists.list" adListDefault="${piholeDir}/adlists.default" -adListRepoDefault="${piholeRepo}/adlists.default" whitelistFile="${piholeDir}/whitelist.txt" blacklistFile="${piholeDir}/blacklist.txt" @@ -133,9 +131,7 @@ gravity_GetBlocklistUrls() { # Determine if adlists file needs handling if [[ ! -f "${adListFile}" ]]; then - # Create "adlists.list" by copying "adlists.default" from internal core repo - cp "${adListRepoDefault}" "${adListFile}" 2> /dev/null || \ - echo -e " ${CROSS} Unable to copy ${adListFile##*/} from ${piholeRepo}" + echo -e " ${CROSS} No adlists file found. Nothing to do!" elif [[ -f "${adListDefault}" ]] && [[ -f "${adListFile}" ]]; then # Remove superceded $adListDefault file rm "${adListDefault}" 2> /dev/null || \ From 2e4f49a223cc2ef83aca361eaa92d50fda05f6b6 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 17 Apr 2018 16:22:10 +0100 Subject: [PATCH 2/4] Default all to on, change up wording. This commit can be rolled back, it's just an option! Signed-off-by: Adam Warner --- automated install/basic-install.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 87e10751..cce15fa3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -959,15 +959,15 @@ setAdminFlag() { # A function to display a list of example blocklists for users to select chooseBlocklists() { # Let user select (or not) blocklists via a checklist - cmd=(whiptail --separate-output --checklist "In order to block ads Pi-Hole relies on blacklists, either sourced from third party curated lists, or through building up a custom blacklist.\\n\\nBelow you will find some examples of third party lists.\\n\\nPlease note, the installation can be completed without any of these lists selected, but nothing will be blocked until you add your own." "${r}" "${c}" 7) + cmd=(whiptail --separate-output --checklist "Pi-hole relies on third party lists in order to block ads.\\n\\nYou can use the suggestions below, and/or add your own after installation\\n\\nTo deselect any list, use the arrow keys and spacebar" "${r}" "${c}" 7) # In an array, show the options available (all off by default): - options=(StevenBlack "StevenBlack's Unified Hosts List" off - MalwareDom "MalwareDomains" off - Cameleon "Cameleon" off - ZeusTracker "ZeusTracker" off - DisconTrack "Disconnect.me Tracking" off - DisconAd "Disconnect.me Ads" off - HostsFile "Hosts-file.net Ads" off) + options=(StevenBlack "StevenBlack's Unified Hosts List" on + MalwareDom "MalwareDomains" on + Cameleon "Cameleon" on + ZeusTracker "ZeusTracker" on + DisconTrack "Disconnect.me Tracking" on + DisconAd "Disconnect.me Ads" on + HostsFile "Hosts-file.net Ads" on) # In a variable, show the choices available; exit if Cancel is selected choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) || { echo -e " ${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}"; exit 1; } @@ -984,9 +984,7 @@ chooseBlocklists() { DisconAd ) echo "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt" >> "${adlistFile}";; HostsFile ) echo "https://hosts-file.net/ad_servers.txt" >> "${adlistFile}";; esac - done - - + done } # Check if /etc/dnsmasq.conf is from pi-hole. If so replace with an original and install new in .d directory From b6b1dcb275021674ad030709a83a22b563adce4d Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 17 Apr 2018 19:35:46 +0100 Subject: [PATCH 3/4] delete adlists.list if user cancels out of this dialog Signed-off-by: Adam Warner --- automated install/basic-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index cce15fa3..5b274e47 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -957,10 +957,10 @@ setAdminFlag() { } # A function to display a list of example blocklists for users to select -chooseBlocklists() { +chooseBlocklists() { # Let user select (or not) blocklists via a checklist cmd=(whiptail --separate-output --checklist "Pi-hole relies on third party lists in order to block ads.\\n\\nYou can use the suggestions below, and/or add your own after installation\\n\\nTo deselect any list, use the arrow keys and spacebar" "${r}" "${c}" 7) - # In an array, show the options available (all off by default): + # In an array, show the options available (all off by default): options=(StevenBlack "StevenBlack's Unified Hosts List" on MalwareDom "MalwareDomains" on Cameleon "Cameleon" on @@ -970,7 +970,7 @@ chooseBlocklists() { HostsFile "Hosts-file.net Ads" on) # In a variable, show the choices available; exit if Cancel is selected - choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) || { echo -e " ${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}"; exit 1; } + choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) || { echo -e " ${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}"; rm "${adlistFile}" ;exit 1; } # For each choice available, for choice in ${choices} do From 7455ac9bfbb60054cec5c88247ba934ab3dd7ab4 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 17 Apr 2018 19:46:36 +0100 Subject: [PATCH 4/4] Run chooseBlocklists on EVERY reconfigure, not only if the adlist file does not esist. Signed-off-by: Adam Warner --- 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 5b274e47..7faed6d3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -958,6 +958,10 @@ setAdminFlag() { # A function to display a list of example blocklists for users to select chooseBlocklists() { + # Back up any existing adlist file, on the off chance that it exists. Useful in case of a reconfigure. + if [[ -f "${adlistFile}" ]]; then + mv "${adlistFile}" "${adlistFile}.old" + fi # Let user select (or not) blocklists via a checklist cmd=(whiptail --separate-output --checklist "Pi-hole relies on third party lists in order to block ads.\\n\\nYou can use the suggestions below, and/or add your own after installation\\n\\nTo deselect any list, use the arrow keys and spacebar" "${r}" "${c}" 7) # In an array, show the options available (all off by default): @@ -1708,7 +1712,7 @@ update_dialogs() { strAdd="You will be updated to the latest version." fi opt2a="Reconfigure" - opt2b="This will allow you to enter new settings" + opt2b="This will reset your Pi-hole and allow you to enter new settings." # Display the information to the user UpdateCmd=$(whiptail --title "Existing Install Detected!" --menu "\\n\\nWe have detected an existing install.\\n\\nPlease choose from the following options: \\n($strAdd)" ${r} ${c} 2 \ @@ -2132,10 +2136,8 @@ main() { chooseInterface # Decide what upstream DNS Servers to use setDNS - # If adlists.list file does not exist, give the user the choice of adding some example lists - if [[ ! -f "${adlistFile}" ]]; then - chooseBlocklists - fi + # Give the user a choice of blocklists to include in their install. Or not. + chooseBlocklists # Let the user decide if they want to block ads over IPv4 and/or IPv6 use4andor6 # Let the user decide if they want the web interface to be installed automatically