From 5f931553b9fb1dd3ca08efea40fc27bb6b4d0292 Mon Sep 17 00:00:00 2001 From: pizzafritta Date: Mon, 30 Mar 2015 22:59:18 +0200 Subject: [PATCH] grep whitelist misplaced --- gravity-adv.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity-adv.sh b/gravity-adv.sh index c6a2ba62..3250811b 100755 --- a/gravity-adv.sh +++ b/gravity-adv.sh @@ -64,8 +64,9 @@ echo "Removing duplicates, whitelisting, and formatting the list of domains..." grep -vhE "^\s*(#|$)" $tmpAdList| sed $'s/\r$//'| awk -F. '{for (i=NF; i>1; --i) printf "%s.",$i;print $1}'| - sort -t'.' -k1,2| uniq | grep -vwf $tmpWhiteList | + sort -t'.' -k1,2| uniq | awk -F. 'NR!=1&&substr($0,1,length(p))==p {next} {p=$0".";for (i=NF; i>1; --i) printf "%s.",$i;print $1}'| + grep -vwf $tmpWhiteList | awk -v "IP=$piholeIP" '{sub(/\r$/,""); print "address=/"$0"/"IP}' > $tmpConf numberOfSitesWhitelisted=$(cat $tmpWhiteList | wc -l | sed 's/^[ \t]*//') numberOfSitesBlacklisted=$(cat $tmpBlackList | wc -l | sed 's/^[ \t]*//')