]> Sergey Matveev's repositories - feeder.git/blob - cmd/download
Trivial style fixes
[feeder.git] / cmd / download
1 #!/bin/sh -e
2
3 cmds="$(dirname "$(realpath -- "$0")")"
4 . "$cmds/env.rc"
5 cd "$1"
6 read url < url
7 [ -s etag ] && etag_compare="--etag-compare etag" || :
8 [ -r out ] && time_cond="--time-cond out" || :
9 [ -z "$FEEDER_CURL_VERBOSE" ] && silent="--silent" || silent="--verbose"
10 ${CURL:-curl} --fail \
11     --tcp-fastopen \
12     --user-agent "$FEEDER_USER_AGENT" \
13     --compressed \
14     --location --max-redirs 2 \
15     --dump-header hdr \
16     --output out \
17     --remote-time \
18     --etag-save etag \
19     --max-time $FEEDER_CURL_MAX_TIME \
20     $etag_compare \
21     $time_cond \
22     $silent \
23     "$url" >&2
24 if [ -s out ] ; then
25     $ZSTD < out > feed.zst
26     touch -r out feed.zst
27     truncate -s 0 out
28     touch -r feed.zst out
29 fi
30 $SHA512 < feed.zst > download.hash