3 # Curl flags to handle redirects, not use EPSV, handle cookies for
4 # servers to need them during redirects, and work on SSL without a
5 # certificate (this isn't a security problem because we check the
6 # cryptographic hash of the output anyway).
15 --cookie-jar cookies \
30 if curl
--retry 0 --head --silent "localhost:5001" > /dev
/null
; then
31 echo "\e[0m\e[01;36m=IPFS=\e[0m add $ipfs"
32 tar --owner=root
--group=root
-cWf "source.tar" $
(echo *)
33 res
=$
(curl
-# -F "file=@source.tar" "localhost:5001/api/v0/tar/add" | sed 's/.*"Hash":"\(.*\)".*/\1/')
34 if [ $ipfs != $res ]; then
35 echo "\`ipfs tar add' results in $res when $ipfs is expected"
47 if curl
--retry 0 --head --silent "localhost:5001" > /dev
/null
; then
49 echo "\e[0m\e[01;36m=IPFS=\e[0m get $ipfs"
50 # if we get error code 18, resume partial download
51 while [ $curlexit -eq 18 ]; do
52 # keep this inside an if statement, since on failure it doesn't abort the script
53 if $curl -C - "http://localhost:5001/api/v0/tar/cat?arg=$ipfs" --output "$ipfs.tar"; then
54 unpackFile
"$ipfs.tar"
65 if test -n "$url"; then
67 echo "Downloading $url"
68 while [ $curlexit -eq 18 ]; do
69 # keep this inside an if statement, since on failure it doesn't abort the script
70 if $curl "$url" -O; then
84 echo "\e[01;31merror:\e[0m cannot download $ipfs from ipfs or the given url"