Last active
March 30, 2017 21:00
-
-
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
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 | |
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