]> Sergey Matveev's repositories - feeder.git/blobdiff - cmd/download.sh
Use curl's --max-time
[feeder.git] / cmd / download.sh
index b3a42a6888742b806b21d667fefa6d90c24c4bd0..50f9268fabba3601e384c5d525f438575c8abbcc 100755 (executable)
@@ -1,28 +1,29 @@
 #!/bin/sh -e
 
-PROXY="--proxy http://localhost:8080/"
+cmds="$(dirname "$(realpath -- "$0")")"
+. "$cmds/env.rc"
 cd "$1"
 read url < url
-[ -s etag ] && etag_compare="--etag-compare etag" || etag_compare=""
-[ -r out ] && time_cond="--time-cond out" || time_cond=""
+[ -s etag ] && etag_compare="--etag-compare etag" || :
+[ -r out ] && time_cond="--time-cond out" || :
 [ -z "$FEEDER_CURL_VERBOSE" ] && silent="--silent" || silent="--verbose"
-curl --fail \
-    --user-agent "go.stargrave.org-feeder/0.1.0" \
+${CURL:-curl} --fail \
+    --user-agent "$FEEDER_USER_AGENT" \
     --compressed \
     --location --max-redirs 2 \
     --dump-header hdr \
     --output out \
     --remote-time \
     --etag-save etag \
-    $PROXY \
+    --max-time $FEEDER_CURL_MAX_TIME \
     $etag_compare \
     $time_cond \
     $silent \
     "$url" >&2
 if [ -s out ] ; then
-    zstdmt -19 < out > feed.zst
+    $ZSTD < out > feed.zst
     touch -r out feed.zst
     truncate -s 0 out
     touch -r feed.zst out
 fi
-sha512 < feed.zst > download.hash
+$SHA512 < feed.zst > download.hash