-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpush_to_ipfs.sh
More file actions
executable file
·29 lines (21 loc) · 854 Bytes
/
push_to_ipfs.sh
File metadata and controls
executable file
·29 lines (21 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#/bin/bash
set -u
set -e
tmpfile=.ipfs_update.tmp
echo "adding recursively..."
ipfs add -r root > $tmpfile
# the top directory hash in the last line, that's convenient!
hash=$(tail -n 1 $tmpfile | cut -f 2 -d ' ')
echo $hash > root_hash.txt
echo "new root hash: $hash - persisted to file root_hash.txt"
node_id=$(ipfs id -f="<id>\n")
echo "updating ipns... (node id: $node_id)"
ipfs name publish $hash > $tmpfile
# example output:
# Published to QmfJ4cFrE5NHwqqsAtwWW3uP2n1emVJQf6H6g71f7ZHs8T: QmXsbfuGCcm91te2hx4aNLGFJhfrWzgvuB4cKebcbBNt8k
#ipns_hash=$(cat $tmpfile | cut -f 3 -d ' ')
# This works for me, but it may be safer to parse this with sed, e.g. in order to avoid failure with localized ipfs client
#ipns_hash=$(sed 's/.*\(\w\{46\}\).*\w\{46\}.*/\1/' $tmpfile)
# but - why did I want to parse this??
echo "all done. enjoy!"
rm $tmpfile