From 3abb4f3cf0108834ef4dfbcbf084496c6ffa6e30 Mon Sep 17 00:00:00 2001 From: qo-op Date: Mon, 21 Jun 2021 09:57:46 +0200 Subject: [PATCH] ipfs_FRIENDS_refresh.sh --- zen/ipfs_FRIENDS_refresh.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 zen/ipfs_FRIENDS_refresh.sh diff --git a/zen/ipfs_FRIENDS_refresh.sh b/zen/ipfs_FRIENDS_refresh.sh new file mode 100755 index 0000000..58d0804 --- /dev/null +++ b/zen/ipfs_FRIENDS_refresh.sh @@ -0,0 +1,37 @@ +#!/bin/bash +######################################################################## +# Author: Fred (support@qo-op.com) +# Version: 2021.03.21 +# 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) && [[ ! $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=5s id -f='\n') && [[ "$IPFSNODEID" == "" ]] && echo 'ERROR missing IPFS Node id !! IPFS is not installed !?' && exit 1 +######################################################################## +######################################################################## +# This script is controling IPFS swarm +# Sync friends peers ~/.zen/ipfs/ into ~/.zen/ipfs_swarm/.IPFSNODEID's/ directories +# add not friend_of_mine IPs to fail2ban +######################################################################## +######################################################################## +## SYNC WITH FRIENDS +# _____ ____ ___ _____ _ _ ____ +# | ___| _ \|_ _| ____| \ | | _ \ +# | |_ | |_) || || _| | \| | | | | +# | _| | _ < | || |___| |\ | |_| | +# |_| |_| \_\___|_____|_| \_|____/ +# +# +for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS); +do + ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id) + echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/" + ipfs --timeout=20s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid +done + + +exit 0