#!/bin/bash ######################################################################## # Author: Fred (support@qo-op.com) # Version: 2021.05.17 # 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##*/}" countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l) [[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0 YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1 G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1 IPFSNODEID=$(ipfs --timeout=20s id -f='\n') || echo 'ERROR missing IPFS Node id !! IPFS is not installed !?' && exit 1 ######################################################################## ######################################################################## # This script is refreshing all IPFS swarm to .mycode UNITY ######################################################################## ######################################################################## echo ' ___ _ _ __ __ _ | |_)|_(_ (_\ //\ |_)|\/| _|_| | __) __)\/\//--\| \| | renew ' echo "I am $IPFSNODEID RESTARTING ~/.zen/astrXbian/A_boostrap_nodes.txt" ## SWITCHING OFF rm -f ~/.zen/ipfs/.$IPFSNODEID/.switch sudo systemctl stop ipfs sleep 10 ## RESTORE BOOTSTRAP ipfs bootstrap rm --all for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments do ipfsnodeid=${bootnode##*/} [[ "$ipfsnodeid" != "$IPFSNODEID" ]] && sleep 20 ## RALENTIR DEMARRAGE STATIONS NON BOOTSTRAP ## ADD $bootnode TO BOOTSTRAP ipfs bootstrap add $bootnode done ## STOP FOR $1 sec [[ "$1" =~ ^[0-9]+$ ]] && sleep $1 ## RESTART sudo systemctl restart ipfs sleep 20 # REFRESH IPNS SELF PUBLISH ######################################################################## ~/.zen/astrXbian/zen/ipns_self_publish.sh ######################################################################## ## DEBUG :: Message to onelove ipfs swarm peers > /tmp/ipfs_swarm_peers ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d "Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS" -t "SWARM renew" -f /tmp/ipfs_swarm_peers exit 0