Skip to content

Instantly share code, notes, and snippets.

@d10r
Last active March 30, 2017 21:00
Show Gist options
  • Save d10r/371db3b19e0b0a322d957f088b3aeb72 to your computer and use it in GitHub Desktop.
Save d10r/371db3b19e0b0a322d957f088b3aeb72 to your computer and use it in GitHub Desktop.
Remote part of a simple ipfs replication solution. To be executed by a cronjob
#/bin/bash
set -e
set -u
# that's where my ipfs executable currently lives
PATH=$PATH:/usr/local/bin/
LOCAL_PINS_FILE="$HOME/.ipfs/pinned.list"
# update local list
ipfs pin ls -q --type=recursive > $LOCAL_PINS_FILE
# lists of remote files/hashes are expected in files with name pattern <hostname>.pinned.list
for list in $HOME/.ipfs/*.pinned.list; do
echo "checking $list"
for p in `cat $list`; do
if ! grep -q $p $LOCAL_PINS_FILE; then
echo "adding $p"
ipfs pin add $p;
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment