[macOS] added curl method for param download
This commit is contained in:
@@ -14,10 +14,12 @@ SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')"
|
|||||||
|
|
||||||
WGETCMD="$(command -v wget || echo '')"
|
WGETCMD="$(command -v wget || echo '')"
|
||||||
IPFSCMD="$(command -v ipfs || echo '')"
|
IPFSCMD="$(command -v ipfs || echo '')"
|
||||||
|
CURLCMD="$(command -v curl || echo '')"
|
||||||
|
|
||||||
# fetch methods can be disabled with ZC_DISABLE_SOMETHING=1
|
# fetch methods can be disabled with ZC_DISABLE_SOMETHING=1
|
||||||
ZC_DISABLE_WGET="${ZC_DISABLE_WGET:-}"
|
ZC_DISABLE_WGET="${ZC_DISABLE_WGET:-}"
|
||||||
ZC_DISABLE_IPFS="${ZC_DISABLE_IPFS:-}"
|
ZC_DISABLE_IPFS="${ZC_DISABLE_IPFS:-}"
|
||||||
|
ZC_DISABLE_CURL="${ZC_DISABLE_CURL:-}"
|
||||||
|
|
||||||
function fetch_wget {
|
function fetch_wget {
|
||||||
if [ -z "$WGETCMD" ] || ! [ -z "$ZC_DISABLE_WGET" ]; then
|
if [ -z "$WGETCMD" ] || ! [ -z "$ZC_DISABLE_WGET" ]; then
|
||||||
@@ -56,6 +58,26 @@ EOF
|
|||||||
ipfs get --output "$dlname" "$SPROUT_IPFS/$filename"
|
ipfs get --output "$dlname" "$SPROUT_IPFS/$filename"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetch_curl {
|
||||||
|
if [ -z "$CURLCMD" ] || ! [ -z "$ZC_DISABLE_CURL" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local filename="$1"
|
||||||
|
local dlname="$2"
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
Retrieving (curl): $SPROUT_URL/$filename
|
||||||
|
EOF
|
||||||
|
|
||||||
|
curl \
|
||||||
|
--output "$dlname" \
|
||||||
|
-# -L -C - \
|
||||||
|
"$SPROUT_URL/$filename"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function fetch_failure {
|
function fetch_failure {
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
|
|
||||||
@@ -64,6 +86,7 @@ Try installing one of the following programs and make sure you're online:
|
|||||||
|
|
||||||
* ipfs
|
* ipfs
|
||||||
* wget
|
* wget
|
||||||
|
* curl
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
@@ -77,7 +100,7 @@ function fetch_params {
|
|||||||
|
|
||||||
if ! [ -f "$output" ]
|
if ! [ -f "$output" ]
|
||||||
then
|
then
|
||||||
for method in wget ipfs failure; do
|
for method in wget ipfs curl failure; do
|
||||||
if "fetch_$method" "$filename" "$dlname"; then
|
if "fetch_$method" "$filename" "$dlname"; then
|
||||||
echo "Download successful!"
|
echo "Download successful!"
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user