aboutsummaryrefslogtreecommitdiff
path: root/scripts/download-archive
blob: e8cce169a373876724f474314ce8efa259d8b483 (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
#!/bin/sh

set -e
set -u

fatal () {
    echo "$@" >&2
    exit 1
}

archive="$1"
url="$2"
shift 2

wget=`type -p wget || true`
curl=`type -p curl || true`

if [ -n "$wget" ]; then
    $wget -c -O "$archive" "$url" || rm -f "$archive"
elif [ -n "$curl" ]; then
    $curl "$url" > "$archive" || rm -f "$archive"
else
    fatal "Don't know howto download"
fi