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