#!/bin/bash

# Takes IP/Hostname and work directory as arguments.  Can be called as follows from cron:
# (echo set -- 0.0.0.0 /tmp; curl http://repository.contegix.com/software/temp/wbtest.sh 2>/dev/null) | bash

# base=5d633a068a81668ecbd5b2b29d68fa2a
# Changed 8/11
base=024b89f0dd3494894f00ac93d2ecab65

ip=$1
work=$2

log=wbtest.log

if [[ $ip == "" ]]; then echo "What are you doing?!?!?"; exit; fi
if [[ -e $work ]]; then cd $work; else cd /tmp; fi

d=`date +%Y%m%d-%H%M%S`
curl -o installer.swf.$d http://$ip/flash/installer.swf 2>/dev/null

md5=`md5sum installer.swf.$d | awk '{print $1}'`

if [[ $md5 != $base ]]; then result=CORRUPTED; else result=OK; rm -f installer.swf.$d; fi

echo "`date` : $ip : $result" >> $log


