From 88d4108f920740e0408ccc4703330d3364b5b6fd Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 17 Apr 2018 09:50:25 +0100 Subject: [PATCH] - 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 || \