updatebanhost (495B)
1 #!/bin/sh 2 3 file=/tmp/banhost 4 5 gethosts() { 6 logger -t "banhost[$$]" "Update $file" 7 wget -qO- http://winhelp2002.mvps.org/hosts.txt |awk 'BEGIN{printf "0.0.0.0"}/^0\.0\.0\.0/{printf " "$2}END{exit(!FNR)}' >$file || exit 1 8 echo -n $time >$file.time 9 exec killall -HUP dnsmasq 10 } 11 12 if [ "$ACTION" = ifup -a "$INTERFACE" = wan ]; then 13 read time </proc/uptime 14 time=${time%%.*} 15 16 [ -f $file -a -f $file.time ] || gethosts 17 read oldtime <$file.time 18 [ $((time - oldtime)) -lt 604800 ] || gethosts 19 fi