Update hostblock script

I use this script to update my second host file. See post Second Host file to block internet garbage for more information on this and how to put this script to use.


if [ $(id -u) != "0" ]; then
echo "Must be root to run $0"
exit 1

OLDDATE=$(grep Updated $HOSTFILE |awk '{print $4}')
wget --progress=dot -O $HOSTFILE http://www.mvps.org/winhelp2002/hosts.txt
NEWDATE=$(grep Updated $HOSTFILE |awk '{print $4}')
dos2unix $HOSTFILE

if [ "$OLDDATE" != "$NEWDATE" ]; then
echo "$HOSTFILE updated $NEWDATE"
/sbin/service dnsmasq restart

Leave a Reply

Your email address will not be published. Required fields are marked *