astrXbian/zen/ipns_self_publish.sh

21 lines
1009 B
Bash
Executable File

#!/bin/bash
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
########################################################################
IPFSNODEID=$(ipfs --timeout=5s id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "ipfs TIMEOUT" && exit 1
########################################################################
echo "PUBLISHING ~/.zen/ipfs SELF http://127.0.0.1:8181/ipns/$IPFSNODEID"
MIPFS=$(ipfs --timeout=60s add -rHq ~/.zen/ipfs | tail -n 1)
OLDCHAIN=$(cat ~/.zen/ipfs/.${IPFSNODEID}/.chain)
if [[ "$OLDCHAIN" != "$MIPFS" ]] # MODIFY CHAIN only if something was changed
then
echo "$(date -u +%s%N | cut -b1-13)" > ~/.zen/ipfs/.${IPFSNODEID}/.timestamp
echo $MIPFS > ~/.zen/ipfs/.${IPFSNODEID}/.chain
NODEIPNS=$(ipfs --timeout=60s name publish --quieter /ipfs/$MIPFS)
fi
########################################################################