blob: be94d39f66af7c18a85b5561285cc2f77a034d9b (
plain)
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
|
#!/bin/sh
set -eu
if [ $# -lt 3 ]; then
echo "Error: arguments base_url, file_url and target_file required." >&2
exit 1
fi
base_url="$1"
file_url="$2"
target_file="$3"
success=false
rm -f "$target_file"
for i in 1 2 3; do
echo "Downloading ..." >&2
curl -fLC - --retry 5 --retry-delay 3 -A Mozilla -o "$target_file" "$file_url"
echo "Checking ..." >&2
if gunzip -c "$target_file" | tar t > /dev/null; then
success=true
break
fi
if [ $i -lt 3 ]; then
rm -f "$target_file"
echo "Warning: invalid tarball - retrying." >&2
else
echo "Error: invalid tarball." >&2
fi
done
[ "$success" = "true" ] && exit 0 || exit 1
|