DEFCON3 takes too much time with fail2ban. DEFCON5. ping & FRIENDS swarm sync more regularly

This commit is contained in:
fred 2021-08-05 23:57:29 +02:00
parent 25b414c69c
commit ebd47017c3
5 changed files with 25 additions and 19 deletions

2
DEFCON
View File

@ -1 +1 @@
4 5

View File

@ -11,6 +11,8 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}" 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
source $HOME/.profile source $HOME/.profile
# CORRECT PATH # CORRECT PATH
@ -92,6 +94,10 @@ fi
# RUN TIME $runtime # RUN TIME $runtime
echo "RUNTIME $runtime mn ($timebar)" echo "RUNTIME $runtime mn ($timebar)"
## PING ALL MY FRIENDS TO ENHANCE SWARM CONNECTIVITY
echo "## FRIENDS IPFS PINGing"
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=5s -n 3 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
######################################################################## ########################################################################
## CHECK & (RE)ACTIVATE ipfs p2p tunnels ## CHECK & (RE)ACTIVATE ipfs p2p tunnels
######################################################################## ########################################################################
@ -162,11 +168,6 @@ if [[ $(($minute % 15)) == 0 ]]; then
## RESTORE index.html from /tmp/ipfsindex.html ## RESTORE index.html from /tmp/ipfsindex.html
[[ -f /tmp/ipfsindex.html ]] && mv /tmp/ipfsindex.html ~/.zen/ipfs/index.html [[ -f /tmp/ipfsindex.html ]] && mv /tmp/ipfsindex.html ~/.zen/ipfs/index.html
## PING ALL MY FRIENDS TO ENHANCE SWARM CONNECTIVITY
echo "## FRIENDS IPFS PINGing"
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=5s -n 3 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
fi fi
# __ __ _____ ____ # __ __ _____ ____

View File

@ -135,7 +135,7 @@ echo "####################################################"
# ipfs SWARM shaping # ipfs SWARM shaping
[[ $(cat ~/.zen/A_my_swarm.txt | wc -l) -gt 0 ]] && ~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh && exit 0 || echo "SWARM LOST !! " [[ $(cat ~/.zen/A_my_swarm.txt | wc -l) -gt 0 ]] && ~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh && exit 0 || echo "SWARM LOST !! "
## SHOULD HAVE exit 0 before !!
######################################################################## ########################################################################
## SWARM LOST !! EMERGENCY RECOVERY !! TEST CODE ## SWARM LOST !! EMERGENCY RECOVERY !! TEST CODE
######################################################################## ########################################################################

View File

@ -7,6 +7,8 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}" 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 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 G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1
@ -20,20 +22,20 @@ IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n')
######################################################################## ########################################################################
######################################################################## ########################################################################
## SYNC WITH FRIENDS ## SYNC WITH FRIENDS
# _____ ____ ___ _____ _ _ ____ # _____ ____ ___ _____ _ _ ____
# | ___| _ \|_ _| ____| \ | | _ \ # | ___| _ \|_ _| ____| \ | | _ \
# | |_ | |_) || || _| | \| | | | | # | |_ | |_) || || _| | \| | | | |
# | _| | _ < | || |___| |\ | |_| | # | _| | _ < | || |___| |\ | |_| |
# |_| |_| \_\___|_____|_| \_|____/ # |_| |_| \_\___|_____|_| \_|____/
# #
# #
for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS); for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS);
do do
[[ "$g1id" == "index.html" ]] && continue [[ "$g1id" == "index.html" ]] && continue
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id) ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id)
echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/" echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
ipfs --timeout=20s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
[[ -f /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && cat /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid || echo "NO ZUID" [[ -f /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && cat /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid || echo "NO ZUID"
done done

View File

@ -7,6 +7,9 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}" 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 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 G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1
IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n') || echo 'ERROR missing IPFS Node id !! IPFS is not installed !?' && exit 1 IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n') || echo 'ERROR missing IPFS Node id !! IPFS is not installed !?' && exit 1
@ -17,7 +20,7 @@ IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n') || echo 'ERROR missing IPFS Node
######################################################################## ########################################################################
echo ' echo '
___ _ _ __ __ _ ___ _ _ __ __ _
| |_)|_(_ (_\ //\ |_)|\/| | |_)|_(_ (_\ //\ |_)|\/|
_|_| | __) __)\/\//--\| \| | renew _|_| | __) __)\/\//--\| \| | renew
@ -30,14 +33,14 @@ rm -f ~/.zen/ipfs/.$IPFSNODEID/.switch
sudo systemctl stop ipfs sudo systemctl stop ipfs
sleep 10 sleep 10
## RESTORE BOOTSTRAP ## RESTORE BOOTSTRAP
ipfs bootstrap rm --all ipfs bootstrap rm --all
for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
do do
ipfsnodeid=${bootnode##*/} ipfsnodeid=${bootnode##*/}
[[ "$ipfsnodeid" != "$IPFSNODEID" ]] && sleep 20 ## RALENTIR DEMARRAGE STATIONS NON BOOTSTRAP [[ "$ipfsnodeid" != "$IPFSNODEID" ]] && sleep 20 ## RALENTIR DEMARRAGE STATIONS NON BOOTSTRAP
## ADD $bootnode TO BOOTSTRAP ## ADD $bootnode TO BOOTSTRAP
ipfs bootstrap add $bootnode ipfs bootstrap add $bootnode
done done
## STOP FOR $1 sec ## STOP FOR $1 sec