From 8bad56e89799f05d64d30d367361e9814b48f03c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 17 Jun 2017 14:24:30 +0200 Subject: [PATCH] Improve displayed messages and overall logic --- gravity.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gravity.sh b/gravity.sh index 558cbd18..f333b706 100755 --- a/gravity.sh +++ b/gravity.sh @@ -236,9 +236,7 @@ gravity_Blacklist() { if [[ -f "${blacklistFile}" ]]; then numBlacklisted=$(wc -l < "${blacklistFile}") plural=; [[ "$numBlacklisted" != "1" ]] && plural=s - echo -n "::: Blacklisting $numBlacklisted domain${plural}..." - cat "${blacklistFile}" > "${blackList}.tmp" - echo " done!" + echo "::: Exact blocked domain${plural}: $numBlacklisted" else echo "::: Nothing to blacklist!" fi @@ -345,12 +343,16 @@ gravity_hostFormatGravity() { } 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" + if [[ -f "${blacklistFile}" ]]; then + numBlacklisted=$(wc -l < "${blacklistFile}") + # Format domain list as "192.168.x.x domain.com" + gravity_doHostFormat "${blacklistFile}" "${blackList}.tmp" + # Copy the file over as /etc/pihole/black.list so dnsmasq can use it + cp "${blackList}.tmp" "${blackList}" + rm "${blackList}.tmp" + else + echo "::: Nothing to blacklist!" + fi } # blackbody - remove any remnant files from script processes