From 56689ec6351a2dbdcff569bbd79dc7023a08d57a Mon Sep 17 00:00:00 2001 From: Alexander Willner Date: Tue, 15 Aug 2017 01:47:10 +0200 Subject: [PATCH] fixed OOM killer --- adblocker.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/adblocker.sh b/adblocker.sh index e4c762c..0d540da 100755 --- a/adblocker.sh +++ b/adblocker.sh @@ -14,6 +14,8 @@ HOST_LISTS=" http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&startdate%5Bday%5D=&startdate%5Bmonth%5D=&star " +BLOCKTMP1=/tmp/adblocker_tmp1 +BLOCKTMP2=/tmp/adblocker_tmp2 BLOCKLIST=/tmp/adblocker_hostlist BLACKLIST=/etc/adblocker_blacklist WHITELIST=/etc/adblocker_whitelist @@ -48,7 +50,11 @@ done &>/dev/null # grab list of bad domains from the internet IP_REGEX='([0-9]{1,3}\.){3}[0-9]{1,3}' -hosts=$(wget -qO- $HOST_LISTS | awk "/^$IP_REGEX\W/"'{ print "0.0.0.0",$2 }' | sort -uk2) +wget -qO $BLOCKTMP1 $HOST_LISTS +cat $BLOCKTMP1 | awk "/^$IP_REGEX\W/"'{ print "0.0.0.0",$2 }' > $BLOCKTMP2 +cat $BLOCKTMP2 | sort -uk2 > $BLOCKTMP1 +hosts=$(cat $BLOCKTMP1) +rm $BLOCKTMP1 $BLOCKTMP2 # if the download succeeded, recreate the blocklist