From 0a9c2341272d45dd8b161a24d23cc5fe36a50d0c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 17 Jun 2017 13:57:27 +0200 Subject: [PATCH] Add "pihole -g -b" to *only* update black.list (saves a bunch of time when adding/changing only blacklisted files - won'tdownload lal lists, but only processes the blacklist and restars dnsmasq) --- gravity.sh | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/gravity.sh b/gravity.sh index cb6768e4..2b860183 100755 --- a/gravity.sh +++ b/gravity.sh @@ -317,9 +317,8 @@ gravity_doHostFormat() { fi } -gravity_hostFormat() { +gravity_hostFormatLocal() { # Format domain list as "192.168.x.x domain.com" - echo -n "::: Formatting domains into a HOSTS file..." if [[ -f /etc/hostname ]]; then hostname=$( "${piholeDir}/${accretionDisc}" gravity_doHostFormat "${piholeDir}/${eventHorizon}" "${piholeDir}/${accretionDisc}" # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it cp "${piholeDir}/${accretionDisc}" "${adList}" rm "${piholeDir}/${accretionDisc}" +} +gravity_hostFormatBlack() { + # Format domain list as "192.168.x.x domain.com" echo -e "" > "${blackList}.tmp" gravity_doHostFormat "${blackList}.tmp" "${blackList}" # Copy the file over as /etc/pihole/black.list so dnsmasq can use it cp "${blackList}.tmp" "${blackList}" rm "${blackList}.tmp" - echo " done!" } # blackbody - remove any remnant files from script processes @@ -386,11 +390,6 @@ gravity_advanced() { } gravity_reload() { - #Clear no longer needed files... - echo ":::" - echo -n "::: Cleaning up un-needed files..." - rm ${piholeDir}/pihole.*.txt - echo " done!" # Reload hosts file echo ":::" @@ -411,6 +410,7 @@ for var in "$@"; do "-f" | "--force" ) forceGrav=true;; "-h" | "--help" ) helpFunc;; "-sd" | "--skip-download" ) skipDownload=true;; + "-b" | "--blacklist-only" ) blackListOnly=true;; esac done @@ -420,22 +420,39 @@ if [[ "${forceGrav}" == true ]]; then echo " done!" fi -gravity_collapse -gravity_spinup -if [[ "${skipDownload}" == false ]]; then +if [[ ! "${blackListOnly}" == true ]]; then + gravity_collapse + gravity_spinup + if [[ "${skipDownload}" == false ]]; then gravity_Schwarzchild gravity_advanced -else + else echo "::: Using cached Event Horizon list..." numberOf=$(wc -l < ${piholeDir}/${preEventHorizon}) - echo "::: $numberOf unique domains trapped in the event horizon." + echo "::: $numberOf unique domains trapped in the event horizon." + fi + gravity_Whitelist fi -gravity_Whitelist gravity_Blacklist gravity_Wildcard -gravity_hostFormat +echo -n "::: Formatting domains into a HOSTS file..." +if [[ ! "${blackListOnly}" == true ]]; then + gravity_hostFormatLocal + gravity_hostFormatGravity +fi +gravity_hostFormatBlack +echo " done!" + gravity_blackbody +if [[ ! "${blackListOnly}" == true ]]; then + #Clear no longer needed files... + echo ":::" + echo -n "::: Cleaning up un-needed files..." + rm ${piholeDir}/pihole.*.txt + echo " done!" +fi + gravity_reload "${PIHOLE_COMMAND}" status