@@ -642,54 +642,65 @@ function getLocalIp() {
642
642
# Host list: https://ipfs.github.io/public-gateway-checker
643
643
# Given file CID downloads content from a known public IPFS gateway
644
644
# ipfsGet <file> <CID>
645
+ # ipfsGet --file=<file> --cid=<CID> --timeout="30" --url="https://ipfs.example.com/ipfs"
645
646
function ipfsGet() {
646
- local OUT_PATH=$1
647
- local FILE_CID=$2
648
- local PUB_URL=" "
647
+ local cid=" "
648
+ local file=" "
649
+ local url=" "
650
+ local timeout=" "
649
651
650
- local TIMEOUT=30
652
+ getArgs --gargs_throw=false --gargs_verbose=false " $1 " " $2 " " $3 " " $4 "
651
653
652
- if ($( isCID " $FILE_CID " ) ) ; then
653
- echoInfo " INFO: Cleaning up '$OUT_PATH ' and searching for available gatewys..."
654
+ [ -z " $file " ] && file=" $1 "
655
+ [ -z " $cid " ] && cid=" $2 "
656
+ [ -z $timeout ] && timeout=" 30"
654
657
655
- PUB_URL=" https://gateway.ipfs.io/ipfs/${FILE_CID} "
656
- if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $TIMEOUT ) -gt 1 ]] ) ; then
657
- wget --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $OUT_PATH " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from gateway.ipfs.io :("
658
+ local PUB_URL=" "
659
+ local DOWNLOAD_SUCCESS=" false"
660
+
661
+ if ($( isCID " $cid " ) ) ; then
662
+ echoInfo " INFO: Cleaning up '$file ' and searching for available gatewys..."
663
+
664
+ if [ ! -z " $url " ] ; then
665
+ PUB_URL=" ${url} /${cid} "
666
+ if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
667
+ wget --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ${url} :("
668
+ fi
658
669
fi
659
670
660
- PUB_URL=" https://dweb.link /ipfs/${FILE_CID } "
661
- if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $TIMEOUT ) -gt 1 ]] ) ; then
662
- wget --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $OUT_PATH " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from dweb.link :("
671
+ PUB_URL=" https://gateway.ipfs.io /ipfs/${cid } "
672
+ if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
673
+ wget --timeout= " $timeout " -- user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from gateway.ipfs.io :("
663
674
fi
664
675
665
- PUB_URL=" https://ipfs.joaoleitao.org /ipfs/${FILE_CID} "
666
- if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $TIMEOUT ) -gt 1 ]] ) ; then
667
- wget --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $OUT_PATH " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.joaoleitao.org :("
676
+ PUB_URL=" https://dweb.link /ipfs/${cid} "
677
+ if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
678
+ wget --timeout= " $timeout " -- user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from dweb.link :("
668
679
fi
669
680
670
- PUB_URL=" https://ipfs.kira.network /ipfs/${FILE_CID} "
671
- if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $TIMEOUT ) -gt 1 ]] ) ; then
672
- wget --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $OUT_PATH " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.joaoleitao.org :("
681
+ PUB_URL=" https://ipfs.joaoleitao.org /ipfs/${cid} "
682
+ if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
683
+ wget --timeout= " $timeout " -- user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.joaoleitao.org :("
673
684
fi
674
685
675
- PUB_URL=" https://ipfs.kira.network/ipfs/${FILE_CID } "
676
- if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $TIMEOUT ) -gt 1 ]] ) ; then
677
- wget --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $OUT_PATH " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.joaoleitao.org :("
686
+ PUB_URL=" https://ipfs.kira.network/ipfs/${cid } "
687
+ if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
688
+ wget --timeout= " $timeout " -- user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.kira.network :("
678
689
fi
679
690
680
- PUB_URL=" https://ipfs.snggle.com/ipfs/${FILE_CID } "
681
- if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $TIMEOUT ) -gt 1 ]] ) ; then
682
- wget --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $OUT_PATH " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.joaoleitao.org :("
691
+ PUB_URL=" https://ipfs.snggle.com/ipfs/${cid } "
692
+ if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
693
+ wget --timeout= " $timeout " -- user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.snggle.com :("
683
694
fi
684
695
685
- if ( [ " $DOWNLOAD_SUCCESS " != " true" ] || [ ! -f " $OUT_PATH " ] ) ; then
686
- echoErr " ERROR: Failed to locate or download '$FILE_CID ' file from any public IPFS gateway :("
696
+ if ( [ " $DOWNLOAD_SUCCESS " != " true" ] || [ ! -f " $file " ] ) ; then
697
+ echoErr " ERROR: Failed to locate or download '$cid ' file from any public IPFS gateway :("
687
698
return 1
688
699
else
689
- echoInfo " INFO: Success, file '$FILE_CID ' was downloaded to '$OUT_PATH ' from '$PUB_URL '"
700
+ echoInfo " INFO: Success, file '$cid ' was downloaded to '$file ' from '$PUB_URL '"
690
701
fi
691
702
else
692
- echoErr " ERROR: Specified file CID '$FILE_CID ' is NOT valid"
703
+ echoErr " ERROR: Specified file CID '$cid ' is NOT valid"
693
704
return 1
694
705
fi
695
706
}
@@ -726,15 +737,15 @@ function safeWget() {
726
737
local DOWNLOAD_SUCCESS=" false"
727
738
728
739
if (! $( isCommand cosign) ) ; then
729
- echoErr " ERROR: Cosign tool is not installed, please install version v1.13.1 or later."
740
+ echoErr " ERROR: Cosign tool is not installed, please install version v2.0.0 or later."
730
741
return 1
731
742
fi
732
743
733
744
if (! $( isSHA256 " $EXPECTED_HASH_FIRST " ) ) ; then
734
745
if ($( isCID " $EXPECTED_HASH_FIRST " ) ) ; then
735
746
echoInfo " INFO: Detected IPFS CID, searching available gatewys..."
736
747
COSIGN_PUB_KEY=" $TMP_PATH_PUB "
737
- ipfsGet " $COSIGN_PUB_KEY " " $EXPECTED_HASH_FIRST "
748
+ ipfsGet --file= " $COSIGN_PUB_KEY " --cid= " $EXPECTED_HASH_FIRST " --timeout= " 30 "
738
749
739
750
if ($( isFileEmpty $COSIGN_PUB_KEY ) ); then
740
751
echoErr " ERROR: Failed to locate or download public key file '$EXPECTED_HASH_FIRST ' from any public IPFS gateway :("
0 commit comments