-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_latest.sh
executable file
·43 lines (40 loc) · 1.03 KB
/
get_latest.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
owner_url=$1
repo_name=$2
file_request=$3
destination=$4
release_version=$5
if [ -z "$5" ]
then
latest_url=$(wget https://github.com/${owner_url}/${repo_name}/releases/latest --max-redirect=0 2>&1 | grep Location)
# echo "Latest URL: $latest_url"
prefix="Location: https://github.com/${owner_url}/${repo_name}/releases/tag/"
suffix=" [following]"
tail=${latest_url#"$prefix"}
release_version=${tail%"$suffix"}
fi
echo "Requesting release version: $release_version"
wget_received=8
retry_count=0
while [ $wget_received -eq 8 ]
do
wget -q https://github.com/${owner_url}/${repo_name}/releases/download/${release_version}/${file_request}
wget_received=$?
echo "wget received: $wget_received"
if [ $wget_received -ne 0 ]
then
((retry_count=$retry_count+1))
if [ $retry_count -gt 10 ];
then
break
else
sleep 5
fi
fi
done
if [ $wget_received -eq 0 ];
then
unzip -q $file_request -d $destination
rm $file_request
exit 0
fi
exit 1