RUN me to auto PIN ipfs files from my friends

This commit is contained in:
qo-op 2021-02-20 02:03:53 +01:00
parent 9515081154
commit 77bc55a349
1 changed files with 33 additions and 0 deletions

33
zen/tools/autoPINfriends.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
########################################################################
# Author:
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(ipfs id -f='<id>\n')
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
## AUTO PIN FRIENDS ACTIVATION
# /home/fred/.zen/ipfs_swarm/.12D3KooWB2PWQegymKFGdhKGQbyvnp5RQvjFPzz6KC6sxeo3juaB/PIN/QmbkFKpmfaZyFTBNGbnsLDuaQULzLTAS5DBYHjSYVDrFen/2D2LfX7GaQynDooqn1Eb21zavbgcNJucMbjrafe9qxrF
for astrofile in $(ls ~/.zen/ipfs_swarm/.*/PIN/*/* |sort | uniq);
do
# /home/fred/.zen/ipfs_swarm/.12D3KooWB2PWQegymKFGdhKGQbyvnp5RQvjFPzz6KC6sxeo3juaB/PIN/QmbkFKpmfaZyFTBNGbnsLDuaQULzLTAS5DBYHjSYVDrFen/2D2LfX7GaQynDooqn1Eb21zavbgcNJucMbjrafe9qxrF
astroipfs=$(echo $astrofile | cut -d '/' -f 8 )
# PINNING NEW FILE
echo ~/.zen/ipfs/.${IPFSNODEID}/PIN/${astroipfs}
if [[ ! -d ~/.zen/ipfs/.${IPFSNODEID}/PIN/${astroipfs} ]]
then
echo "PIN : $astroipfs"
ipfs pin add /ipfs/$astroipfs && mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/PIN/${astroipfs}/
echo "PUBLISHING MY PIN"
[[ -d ~/.zen/ipfs/.${IPFSNODEID}/PIN/${astroipfs} ]] && touch ~/.zen/ipfs/.${IPFSNODEID}/PIN/${astroipfs}/$G1PUB
fi
# EXIT AFTER ONE PIN ONLY (next PIN in cron_MINUTE time)
[[ -f ~/.zen/ipfs/.${IPFSNODEID}/PIN/${astroipfs}/$G1PUB ]] && break
done