diff options
author | archibald869 | 2019-04-16 14:44:53 +0200 |
---|---|---|
committer | archibald869 | 2019-04-16 14:44:53 +0200 |
commit | 93234c8e390a8f036c06b9f3490f51a26578774e (patch) | |
tree | 52db58b61a60cc7d14be4f43139817dd7d300e7e /dlagent | |
parent | 92c71af2773b318852f9afe577a4860577f79338 (diff) | |
download | aur-93234c8e390a8f036c06b9f3490f51a26578774e.tar.gz |
Use separate script as download agent
Diffstat (limited to 'dlagent')
-rwxr-xr-x | dlagent | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/dlagent b/dlagent new file mode 100755 index 000000000000..93622375622a --- /dev/null +++ b/dlagent @@ -0,0 +1,37 @@ +#!/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 "Authenticating for download ..." >&2 + curl -fsSL -A Mozilla "$base_url/cookie/load-consent.php" > /dev/null + + 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 |