@@ -26,7 +26,7 @@ function bashUtilsVersion() {
26
26
# this is default installation script for utils
27
27
# ./bash-utils.sh bashUtilsSetup "/var/kiraglob"
28
28
function bashUtilsSetup() {
29
- local BASH_UTILS_VERSION=" v0.3.41 "
29
+ local BASH_UTILS_VERSION=" v0.3.42 "
30
30
local COSIGN_VERSION=" v2.0.0"
31
31
if [ " $1 " == " version" ] ; then
32
32
echo " $BASH_UTILS_VERSION "
@@ -652,12 +652,14 @@ function ipfsGet() {
652
652
local file=" "
653
653
local url=" "
654
654
local timeout=" "
655
+ local tries=" "
655
656
656
- getArgs --gargs_throw=false --gargs_verbose=false " $1 " " $2 " " $3 " " $4 "
657
+ getArgs --gargs_throw=false --gargs_verbose=false " $1 " " $2 " " $3 " " $4 " " $5 "
657
658
658
659
[ -z " $file " ] && file=" $1 "
659
- [ -z " $cid " ] && cid=" $2 "
660
- [ -z $timeout ] && timeout=" 30"
660
+ (! $( isCID " $cid " ) ) && cid=" $2 "
661
+ (! $( isNaturalNumber " $timeout " ) ) && timeout=30
662
+ (! $( isNaturalNumber " $tries " ) ) && tries=2
661
663
662
664
local PUB_URL=" "
663
665
local DOWNLOAD_SUCCESS=" false"
@@ -668,33 +670,39 @@ function ipfsGet() {
668
670
if [ ! -z " $url " ] ; then
669
671
PUB_URL=" ${url} /${cid} "
670
672
if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
671
- wget --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ${url} :("
673
+ wget --tries=" $tries " --waitretry=1 --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && \
674
+ DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ${url} :("
672
675
fi
673
676
fi
674
677
675
678
PUB_URL=" https://gateway.ipfs.io/ipfs/${cid} "
676
679
if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
677
- wget --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from gateway.ipfs.io :("
680
+ wget --tries=" $tries " --waitretry=1 --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && \
681
+ DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from gateway.ipfs.io :("
678
682
fi
679
683
680
684
PUB_URL=" https://dweb.link/ipfs/${cid} "
681
685
if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
682
- wget --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from dweb.link :("
686
+ wget --tries=" $tries " --waitretry=1 --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && \
687
+ DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from dweb.link :("
683
688
fi
684
689
685
690
PUB_URL=" https://ipfs.joaoleitao.org/ipfs/${cid} "
686
691
if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
687
- wget --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.joaoleitao.org :("
692
+ wget --tries=" $tries " --waitretry=1 --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && \
693
+ DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.joaoleitao.org :("
688
694
fi
689
695
690
696
PUB_URL=" https://ipfs.kira.network/ipfs/${cid} "
691
697
if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
692
- wget --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.kira.network :("
698
+ wget --tries=" $tries " --waitretry=1 --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && \
699
+ DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.kira.network :("
693
700
fi
694
701
695
702
PUB_URL=" https://ipfs.snggle.com/ipfs/${cid} "
696
703
if ( [ " $DOWNLOAD_SUCCESS " != " true" ] && [[ $( urlContentLength " $PUB_URL " $timeout ) -gt 1 ]] ) ; then
697
- wget --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.snggle.com :("
704
+ wget --tries=" $tries " --waitretry=1 --timeout=" $timeout " --user-agent=" $UBUNTU_AGENT " " $PUB_URL " -O " $file " && \
705
+ DOWNLOAD_SUCCESS=" true" || echoWarn " WARNING: Faild download from ipfs.snggle.com :("
698
706
fi
699
707
700
708
if ( [ " $DOWNLOAD_SUCCESS " != " true" ] || [ ! -f " $file " ] ) ; then
@@ -716,9 +724,19 @@ function ipfsGet() {
716
724
# safeWget <file> <url> <hash>,<hash>,<hash>...
717
725
# safeWget <file> <url> <CID>
718
726
function safeWget() {
719
- local OUT_PATH=$1
720
- local FILE_URL=$2
721
- local EXPECTED_HASH=$3
727
+ local OUT_PATH=" $1 "
728
+ local FILE_URL=" $2 "
729
+ local EXPECTED_HASH=" $3 "
730
+ local timeout=" "
731
+ local sig_timeout=" "
732
+ local waitretry=" "
733
+ local tries=" "
734
+ getArgs --gargs_throw=false --gargs_verbose=false " $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " $7 "
735
+
736
+ (! $( isNaturalNumber " $timeout " ) ) && timeout=900
737
+ (! $( isNaturalNumber " $sig_timeout " ) ) && sig_timeout=30
738
+ (! $( isNaturalNumber " $waitretry " ) ) && waitretry=1
739
+ (! $( isNaturalNumber " $tries " ) ) && tries=2
722
740
723
741
# we need to use MD5 for TMP files to ensure that we download the file again if URL changes
724
742
local OUT_NAME=$( echo " $OUT_PATH " | md5)
@@ -749,7 +767,7 @@ function safeWget() {
749
767
if ($( isCID " $EXPECTED_HASH_FIRST " ) ) ; then
750
768
echoInfo " INFO: Detected IPFS CID, searching available gatewys..."
751
769
COSIGN_PUB_KEY=" $TMP_PATH_PUB "
752
- ipfsGet --file=" $COSIGN_PUB_KEY " --cid=" $EXPECTED_HASH_FIRST " --timeout=" 30 "
770
+ ipfsGet --file=" $COSIGN_PUB_KEY " --cid=" $EXPECTED_HASH_FIRST " --timeout=" $sig_timeout "
753
771
754
772
if ($( isFileEmpty $COSIGN_PUB_KEY ) ); then
755
773
echoErr " ERROR: Failed to locate or download public key file '$EXPECTED_HASH_FIRST ' from any public IPFS gateway :("
@@ -762,7 +780,7 @@ function safeWget() {
762
780
763
781
if (! $( isFileEmpty $COSIGN_PUB_KEY ) ) || ($( urlExists " $COSIGN_PUB_KEY " ) ) ; then
764
782
echoWarn " WARNING: Attempting to fetch signature file..."
765
- wget --user-agent=" $UBUNTU_AGENT " " $SIG_URL " -O $TMP_PATH_SIG
783
+ wget --timeout= " $sig_timeout " --tries= " $tries " --waitretry=1 -- user-agent=" $UBUNTU_AGENT " " $SIG_URL " -O $TMP_PATH_SIG
766
784
else
767
785
echoErr " ERROR: Public key was not found in '$COSIGN_PUB_KEY '"
768
786
return 1
@@ -801,7 +819,7 @@ function safeWget() {
801
819
802
820
if [ " $HASH_MATCH " == " false" ] ; then
803
821
rm -fv $OUT_PATH
804
- wget --user-agent=" $UBUNTU_AGENT " " $FILE_URL " -O $TMP_PATH
822
+ wget --timeout= " $timeout " --tries= " $tries " --waitretry=1 -- user-agent=" $UBUNTU_AGENT " " $FILE_URL " -O $TMP_PATH
805
823
[ " $TMP_PATH " != " $OUT_PATH " ] && cp -fv $TMP_PATH $OUT_PATH
806
824
FILE_HASH=$( sha256 $OUT_PATH )
807
825
fi
@@ -2241,7 +2259,7 @@ fileFollow() {
2241
2259
if (! $( isFileEmpty " $file " ) ) ; then
2242
2260
trap fileFollowInt INT
2243
2261
trap fileFollowErr ERR
2244
- tail -n 1000 -f " $file " &
2262
+ tail -n 2147483646 -f " $file " &
2245
2263
pid=$!
2246
2264
2247
2265
pressToContinue " q"
0 commit comments