-
Notifications
You must be signed in to change notification settings - Fork 0
/
try_get_release.sh
executable file
·38 lines (37 loc) · 1.21 KB
/
try_get_release.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
# ./try_get_release.sh user repo file tag
#
# response=$? # 0=match, -1=corrupt, -2=missing
#
FILE=$4
TAG=$3
URL=https://github.com/$1/$2/releases/download/$TAG/$FILE
echo "checking URL: $URL"
R=$(curl --silent -I $URL | grep -E "^HTTP" | awk -F " " '{print $2}')
RSHA=$(curl --silent -I $URL.sha512 | grep -E "^HTTP" | awk -F " " '{print $2}')
if [[ ("$R" == "200" || "$R" == "302") && ("$RSHA" == "200" || "$RSHA" == "302") ]]
then
echo "file '$FILE' exists in releases"
curl -L $URL.sha512 -o $FILE.sha512
curl -L $URL -o $FILE
cat $FILE.sha512
if sha512sum -c $FILE.sha512
then
echo 'extracting build directory...'
tar -xf $FILE
echo 'extracted build directory'
rm $FILE
rm $FILE.sha512
exit 0
else
echo 'build directory cache corrupted, rebuilding'
mkdir BUILD_DEBUG || true
rm $FILE
rm $FILE.sha512
exit -1
fi
else
echo "URL OR SHA DOES NOT EXIST"
echo 'build directory does not exist in cache'
mkdir BUILD_DEBUG || true
exit -2
fi