6 TEMP_DIR
=$
(/usr
/bin
/mktemp
-t -d moblock-updateXXXXXXXX
)
16 /usr
/bin
/find $TEMP_DIR -type f
-name '*.gz' -o -name '*.zip' |\
20 *.
zip) /usr
/bin
/unzip -oqq "$N" 2>/dev
/null
28 *.gz
) /bin
/gunzip
-f "$N" 2>/dev
/null
43 printf "${C_SEPARATOR} ------------------------------\n"
44 printhl
"Downloading and extracting files:\n"
46 # Bluetack lists (with fallback)
47 for i
in ${BLUETACK[@]}
49 if [ $
(echo $i |
/bin
/grep '^[^\!]' |
/usr
/bin
/wc -l) -eq 1 ]; then
50 stat_busy
"BLUETACK '${i}'... "
51 /usr
/bin
/wget
${WGET_OPTS} "http://www.bluetack.co.uk/config/${i}.gz" && extract
52 if [ $?
-gt 0 ] ||
[ ! -f ${i} ]; then
55 if [ "$bfile" = "ads-trackers-and-bad-pr0n" ]; then
57 elif [ "$bfile" = "Microsoft" ];then
60 stat_busy
"[!!] BLUETACK '${i}' (fallback link)... "
61 /usr
/bin
/wget
${WGET_OPTS} "http://list.iblocklist.com/?list=bt_${bfile%%-*}" -O "${i}.gz
" && extract
74 for i in ${BLOCKLIST[@]}
76 if [ $(echo $i | /bin/grep '^[^\!]' | /usr/bin/wc -l) -eq 1 ]; then
77 stat_busy "BLOCKLIST
'${i}'...
"
78 /usr/bin/wget ${WGET_OPTS} "blocklist.org
/${i}.p2b.gz
" && extract
87 # Old phoenixlabs.org lists
88 for i in ${PHOENIXLABS[@]}
90 if [ $(echo $i | /bin/grep '^[^\!]' | /usr/bin/wc -l) -eq 1 ]; then
91 stat_busy "PHOENIXLABS
'${i}'...
"
92 /usr/bin/wget ${WGET_OPTS} "fox.phoenixlabs.org
/${i}" && extract
101 if [ $(/bin/cat "$TEMP_DIR"/* | /usr/bin/wc -l) -eq 0 ]; then
103 printhl "ERROR
: No files were downloaded
"
104 printf "${C_SEPARATOR} ------------------------------\n"
110 printhl "Checking integrity of downloaded files
:\n"
112 /usr/bin/find -type f | while read N
114 stat_busy "File
'$(echo $N | /bin/awk -F/ '{print
$NF}')'...
"
115 scan1=$(/bin/cat "$N" | /usr/bin/wc -l)
116 scan2=$(/bin/egrep -o ":[0-9]*\.
[0-9]*\.
[0-9]*\.
[0-9]*-[0-9]*\.
[0-9]*\.
[0-9]*\.
[0-9]*" "$N" | /usr/bin/wc -l)
117 if [ $scan1 -eq $scan2 ]; then
120 if [ $scan2 -gt 0 ]; then
121 if [ $scan1 -gt $scan2 ]; then
122 stat_append "$
(($scan1-$scan2)) of
$scan1 entries failed validation
; keeping the
file"
127 stat_busy "[!!] Removing corrupted
file...
"
129 if [ $? -gt 0 ]; then
140 printhl "Saving the list
:\n"
143 if [ "$BACKUP_OLD_LIST" = "yes" ] && [ -f "$CONF_DIR"/"$LIST_FILE" ]; then
144 stat_busy "Backing up old list to
'$CONF_DIR/$LIST_FILE.gz'...
"
145 /bin/gzip -f "$CONF_DIR"/"$LIST_FILE" 2>/dev/null
146 if [ $? -gt 0 ]; then
154 stat_busy "Saving new list to
'$CONF_DIR/$LIST_FILE'...
"
155 /bin/cat "$TEMP_DIR"/* > "$CONF_DIR"/"$LIST_FILE" 2>&1
156 if [ $? -gt 0 ]; then
162 printhl "Saved
`cat "$CONF_DIR"/"$LIST_FILE" | wc -l` ranges
"
163 printf "${C_SEPARATOR} ------------------------------\n"
169 if [ -f /var/run/moblock.pid ]; then
170 /bin/kill -HUP `cat /var/run/moblock.pid` >/dev/null 2>&1