#!/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='\n') G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) # This script is called to manage SWARM autoPIN # Actual behaviour is to accept anything from # SOURCE: ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${g1node}/.ipfsid.encrypt (new_file_in_astroport.sh) ## AUTO PIN FRIENDS ACTIVATION for astrofile in $(ls -dt ~/.zen/ipfs_swarm/.12D*/KEY/*/*/${G1PUB}/.ipfsid.encrypt); do # decrypt $astrofile source=$(echo "$astrofile" | cut -d '/' -f 9 ) echo "PINNING ASKED BY $source" ## VERIFY CONTRACT... TODO $MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$astrofile" -o "/tmp/ipfslink.txt" astrofile=$(cat /tmp/ipfslink.txt) # PINNING NEW FILE echo "SHOULD I PIN ~/.zen/PIN/${astrofile} ??" if [[ ! -d ~/.zen/PIN/${astrofile} ]]; then echo "PIN : $astrofile" ipfs pin add /ipfs/$astrofile && mkdir -p ~/.zen/PIN/${astrofile}/ echo "PUBLISHING MY PIN" [[ -d ~/.zen/PIN/${astrofile} ]] && echo "0" > ~/.zen/PIN/${astrofile}/$G1PUB else echo "ALREADY PINNED" fi # EXIT AFTER ONE PIN ONLY (next PIN in cron_MINUTE time) [[ -f ~/.zen/PIN/${astrofile}/$G1PUB ]] && break done