From ec8f98fa4aa4fa9733f20c437831cb0e93963a1d Mon Sep 17 00:00:00 2001 From: R0GGER <8298741+R0GGER@users.noreply.github.com> Date: Tue, 19 Mar 2019 22:40:18 +0100 Subject: [PATCH] Always update wsusoffline before start... --- update.sh | 75 +++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/update.sh b/update.sh index a99baad..d1538d2 100644 --- a/update.sh +++ b/update.sh @@ -13,53 +13,46 @@ diff --strip-trailing-cr \ "static/StaticDownloadLink-this.txt" \ "static/StaticDownloadLink-recent.txt" > /dev/null -if (( $? == 0 )); then - echo "The installed version of WSUS Offline Update is up-to-date." - exit 0; -else - URL=$(cat static/StaticDownloadLink-recent.txt) - echo 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/* "$BASEPATH" - 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 +URL=$(cat static/StaticDownloadLink-recent.txt) +echo Updating 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 - fi + unzip -q $FILE + cd .. + cp -av /temp/wsusoffline/* "$BASEPATH" + 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 + cd $BASEPATH -# cleanup +# cleanup if [ -d /temp ]; then rm -rf /temp fi -# if you have to set file permissions uncomment some out -# find ../ -type d -print0 | xargs -0 chmod 755 -# find ../ -type f -print0 | xargs -0 chmod 644 -# chown -R nobody.nogroup ../ -# + # make the shell scripts executabal again find ../ -name '*.bash' -print0 | xargs -0 chmod +x find ../ -name '*.sh' -print0 | xargs -0 chmod +x