forked from R0GGER/docker-wsusoffline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
59 lines (53 loc) · 1.72 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Go to script's path as a start:
cd "$(dirname "$0")"
BASEPATH=$(pwd)/wsusoffline
if [ ! -d /temp ]; then
mkdir /temp
fi
wget --timestamping --directory-prefix="static" \
"https://download.wsusoffline.net/StaticDownloadLink-recent.txt"
diff --strip-trailing-cr \
"static/StaticDownloadLink-this.txt" \
"static/StaticDownloadLink-recent.txt" > /dev/null
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/https:\/\/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
fi
fi
cd $BASEPATH
# cleanup
if [ -d /temp ]; then
rm -rf /temp
fi
# make the shell scripts executabal again
find ../ -name '*.bash' -print0 | xargs -0 chmod +x
find ../ -name '*.sh' -print0 | xargs -0 chmod +x
cp -rf /wsus/preferences.bash /wsus/wsusoffline/sh/preferences.bash