I don't know were to post this to the maintainers, i hope they read this.
I am not a very good script writer, bit this works as expected since about a year with good results:
- Code: Select all
#!/bin/bash
#
# Author: Carlos Pasqualini
# email: carlos [at] carlospasqualini.com.ar
# Website: http://www.carlospasqualini.com.ar/
#
# License: GPLv3+
# ../doc/license.txt
#
# disable Debugging
#DEBUG=true
# enable Debugging
DEBUG=echo
# Go to script's path as a start:
cd `dirname $0`
dos2unix -q -n ../doc/history.txt ../temp/history.txt
OLDURL=`head ../temp/history.txt |grep 'WSUS Offline Update '|sed 's/\.//g;s/^WSUS Offline Update /http:\/\/download.wsusoffline.net\/wsusoffline/'|awk '{print $0 ".zip"}'`
URL=`wget -q http://download.wsusoffline.net/rss.xml -O - | grep zip |sed 's/^[ \t]*<link>//;s/<\/link>//'`
$DEBUG OLDURL: $OLDURL
$DEBUG NEWURL: $URL
if [[ $OLDURL != $URL ]]; then
$DEBUG We need to update wsusoffline!
cd ../temp/
wget -q $URL
HASH=`echo $URL |sed 's/\.zip/_hashes.txt/'`
wget -q $HASH
FILE=`echo $URL |sed 's/http:\/\/download.wsusoffline.net\///'`
HASH=`echo $FILE|sed 's/\.zip/_hashes.txt/'`
if [[ -f $FILE ]]; then
SHA256=`sha256sum ../temp/$FILE | awk '{print $1}'`
if [[ `grep -c "$SHA256,$FILE" $HASH` -gt 0 ]]; then
echo Download validated
cd ../temp/
if [[ -d wsusoffline ]]; then
rm -r wsusoffline
fi
unzip -q $FILE
cd ..
cp -av temp/wsusoffline/* .
else
echo Download failed
if [[ -f ../temp/$FILE ]]; then
rm -v ../temp/$FILE
fi
if [[ -f ../temp/$HASH ]]; then
rm -v ../temp/$HASH
fi
if [[ -d ../temp/wsusoffline ]]; then
rm -r ../temp/wsusoffline/
fi
fi
fi
fi
i hope this helps someone and obtain feedback to improve it
Thanks!