#!/bin/sh # nkvir-update.sh - cron this to update your nkvir-rc.gz file nightly # by Rudy Rucker. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. # # Fetch the new nkvir info and then install it. # Do nothing if the file is not newer. # This scrip also strips out all the different virus folders and crams # everything into one virus folder. Erase the 'perl' line below if you # do not want this to occur. # Note from mondeek: if a hacker can affect your DNS lookup of onlinhom.us # hosts, they would be able to inject arbitrary code into your procmail ruleset. # added the PARANOID flag. # set up in a cron, pipe to where you want the output emailed: # 20 0 * * * sleep $[ $RANDOM / 1024 ]; /usr/local/etc/mail/nkvir/update.sh | /usr/bin/mail -E -s "[zone_fetcher] step2" myemail@mail.mon-keybrains.net URL='http://s92562228.onlinehome.us/yavr/nkvir-rc.gz' FILE='nkvir-rc.gz' PARANOID="YES" DIRECTORY="/usr/local/etc/mail/nkvir" # all the foillowing commands assume you are in the right directory... cd $DIRECTORY # Get new file if [ -f $FILE ]; then /usr/bin/touch -r $FILE timestamp else /bin/rm timestamp 2> /dev/null; fi if [ -x /usr/local/bin/wget ]; then # wget is cool... it fill not fetch a file if the mod times don't merit the download /usr/local/bin/wget -N --quiet -U 'Wget - RemoteUpdate/0.3' $URL else /usr/bin/fetch $URL fi # Is it newer? if [ $FILE -nt timestamp ]; then # if the timestamp file does not exist, the if will be FALSE echo "New $FILE downloaded!" echo "Source: $URL" elif [ -f timestamp ] && [ -f nkvir-rc ]; then /bin/rm timestamp; exit; elif [ -f $FILE ]; then echo "Downloaded $FILE for first time!" echo "Source: $URL" PARANOID="no" echo "Will auto install!" else echo "$FILE failed to download..." echo "check your URL: $URL" exit; fi if [ ! -f nkvir-rc ] && [ $PARANOID = "YES" ]; then PARANOID="no" echo "Guess what? I didn't find an installed version of nkvir-rc." echo "This script is going AUTO INSTALL it unless you hit CRTL-C" perl -e '$|=666; for (1..10) {$_ = 11-$_; print "\r $_ seconds till install "; sleep 1}' echo fi # Backup the old one, unzip the new one, patch it, and then install it. # I like to patch it so all the viruses go into one folder. /usr/bin/gunzip -c $FILE > nkvir-rc.dist /bin/cp nkvir-rc.dist nkvir-rc.new /usr/bin/perl -pi -e 's/(\$VIRDIR)\/virus-\S+/$1/' nkvir-rc.new if [ -f nkvir-rc ]; then /bin/ln -f nkvir-rc nkvir-rc.OLD echo "---------------------- /usr/bin/diff nkvir-rc nkvir-rc.new --------------------" /usr/bin/diff nkvir-rc nkvir-rc.new fi if [ $PARANOID = "YES" ]; then echo "--------------------------------------------------------------------------------" echo "Review diffs and Please install new nkvir file manually." echo " mv $DIRECTORY/nkvir-rc.new $DIRECTORY/nkvir-rc" else echo "Will install" sleep 2; /bin/ln -f nkvir-rc.new nkvir-rc unlink nkvir-rc.new echo "Automatically installed new nkvir ruleset. Please review diffs." fi