-
-
Save 4DA/6c11e5bc7018ae0115d1336e9f9a0505 to your computer and use it in GitHub Desktop.
Update IPFS pin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIR=$1 | |
CIDFILE="$1_cid" | |
IPFSOPTS="--nocopy" | |
DNSLINK_UPDATE="~/scripts/dnslink.sh" | |
if [ -f $CIDFILE ]; then | |
CID=`cat $CIDFILE` | |
echo "Current CID=$CID" | |
else | |
CID=`ipfs add -r $DIR $IPFSOPTS -Q` | |
echo "Computed CID = $CID" | |
echo $CID > $CIDFILE | |
fi | |
echo "Starting watching $DIR for changes" | |
while true; do | |
inotifywait -e modify,delete,move,close_write -r $DIR | |
ipfs pin rm $CID | |
NEWCID=`ipfs add -r $DIR $IPFSOPTS -Q` | |
echo "updated $CID -> $NEWCID" | |
CID=$NEWCID | |
$DNSLINK_UPDATE $CID | |
echo $CID > $CIDFILE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment