writing in code comments. please read

This commit is contained in:
qo-op 2021-06-16 01:21:56 +02:00
parent cd53eeed62
commit 6af6406b2e
1 changed files with 26 additions and 21 deletions

View File

@ -84,26 +84,26 @@ fi
# RUN TIME $runtime
echo "RUNTIME $runtime mn ($timebar)"
########################################################################
## CHECK & (RE)ACTIVATE ipfs p2p tunnels
########################################################################
# NextCloud FROM taurus TO oasis (https://taurus.copylaradio.com)
~/.zen/astrXbian/zen/ipfs_P2P_forward.sh
########## SUPPORT : OPEN OR CLOSE SSH ACCESS #################
# [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" == "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # OPEN-SSH
# [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" != "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # CLOSE-SSH
########################################################################
# DEFCON
########################################################################
# STATION CAN MODIFY DEFCON (cool 5 to 1 war) - only 5 and 4 (fail2ban) are ready to use.
[[ -f ~/.zen/DEFCON ]] && export DEFCON=$(cat ~/.zen/DEFCON) || export DEFCON=$(cat ~/.zen/astrXbian/DEFCON) # ADAPT $DEFCON scenario
## DEFCON SYSTEM ACTIVATED
########################################################################
# SMARM SYNCRONISATION
# SMARM MAINTENANCE / 15 mn
########################################################################
# ____ _______ __ __
# / __ \/ ____/ | / / ____ ___ ____ ____/ /__
# / / / / __/ | | / / / __ `__ \/ __ \/ __ / _ \
# / /_/ / /___ | |/ / / / / / / / /_/ / /_/ / __/
# /_____/_____/ |___/ /_/ /_/ /_/\____/\__,_/\___/
#
# astrXbian TestNET
# astrXbian TestNET (git pull) -> desactivate in release ipfs get codeID
########################################################################
# ACTIVATE 15-17 MN "git pull" update
if [[ $(($minute % 15)) == 0 ]]; then
@ -118,21 +118,25 @@ if [[ $(($minute % 15)) == 0 ]]; then
# fi
# CLEAN AND REMOVE BAD DIRECTORIES
## BYPASS index.html DELETION
[[ -f ~/.zen/ipfs/index.html ]] && cp ~/.zen/ipfs/index.html /tmp/ipfsindex.html
[[ -d ~/.zen/ipfs/astroport ]] && rm -Rf ~/.zen/ipfs/astroport
[[ -d ~/.zen/ipfs_swarm/astroport ]] && rm -Rf ~/.zen/ipfs_swarm/astroport
[[ -d ~/.zen/ipfs/xbian ]] && rm -Rf ~/.zen/ipfs/xbian
[[ -d ~/.zen/ipfs_swarm/xbian ]] && rm -Rf ~/.zen/ipfs_swarm/xbian
[[ -d ~/.zen/ipfs/PIN ]] && rm -Rf ~/.zen/ipfs/PIN
[[ -d ~/.zen/ipfs_swarm/PIN ]] && rm -Rf ~/.zen/ipfs_swarm/PIN
## CLEANING OLD BAD FILES
## CLEANING PARASITE BAD FILES
rm ~/.zen/ipfs/*
rm ~/.zen/ipfs/.*
rm ~/.zen/ipfs_swarm/*
rm ~/.zen/ipfs_swarm/.*
## RESTORE index.html from /tmp/ipfsindex.html
[[ -f /tmp/ipfsindex.html ]] && mv /tmp/ipfsindex.html ~/.zen/ipfs/index.html
## CONTROL IPFS IS RUNNING OR RESTART
isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
if [[ ! $isIPFSRunning ]]; then
[[ -f /etc/sudoers.d/systemctl && -f ~/.zen/ipfs/.$IPFSNODEID/.switch ]] && sudo systemctl restart ipfs
@ -140,12 +144,10 @@ if [[ $(($minute % 15)) == 0 ]]; then
exit 1
fi
## PING ALL MY FRIENDS
echo "## FRIENDS IPFS PINGing"
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=7s -n 5 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
########## CHATON : OPEN OR CLOSE SSH ACCESS #################
# [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" == "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # OPEN-SSH
# [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" != "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # CLOSE-SSH
fi
# __ __ _____ ____
@ -156,13 +158,15 @@ fi
#
##################################################################
# TODO: IDEA make gchange/ipfs/ipns refresh speed depending on ipfs swarm size and DEFCON level !
# SYNC GCHANGE EVERY 1 hour runtime
## SYNC GCHANGE EVERY 1 hour runtime
[[ $(($runtime % 60)) == 0 ]] && $MY_PATH/zen/gchange_INIT.sh && $MY_PATH/zen/gchange_IPFS_swarm.sh &
# QUICK SYNC SWARM EVERY 20 minutes +/- 1 minute
# [[ $(($runtime % 20)) == 0 ]] && $MY_PATH/zen/ipfs_SWARM_refresh.sh "quick" &
# ACTIVATE ~/astroport directory monitoring
########################################################################
# ACTIVATE ~/astroport directory monitoring (xbian only)
########################################################################
###
# _ _
# __ _| |__ (_) __ _ _ __
@ -173,7 +177,7 @@ fi
# ON Rpi/xbian files added in ~/astroport are monitored to activate "new_file_in_astroport.sh"
# Transfert ~/astroport/*/files to IPFS and make Astroport/KODI indexes in IPNS
if [[ "$USER" == "xbian" ]]; then
[[ ! -e /home/$USER/astroport ]] && mkdir -p /home/$USER/astroport
[[ ! -e $HOME/astroport ]] && mkdir -p $HOME/astroport
# VERIFY LAUNCH inotifywait ?!
inotifywaitRunning=$(ps auxf --sort=+utime | grep -w inotifywait | grep -w astroport | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
if [[ "$inotifywaitRunning" != "xbian" ]]
@ -192,7 +196,7 @@ fi
# / /_/ __/ / / / / / / ___ / /_/ /
# /___/\___/_/ /_/ /_/ /_/ |_\____/
#
# REFRESHing MEDIAKEY ZenTAG nano DHTs => Zen File ECONOMY wallet cycle
# REFRESHing MEDIAKEY / ZenTAG nano DHTs => Zen File ECONOMY wallet cycle
if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || $(($runtime % 720)) == 0 || $runtime == 12 ]]; then
# Every 12h runtime restarting IPFS daemon
[[ $(($runtime % 720)) == 0 ]] && [[ -f /etc/sudoers.d/systemctl || "$USER" == "xbian" ]] && sudo systemctl restart ipfs && sleep $((12 + RANDOM % 20))
@ -200,13 +204,13 @@ if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || $(($runtime % 720)) == 0
#### Refresh & publish MEDIAKEYs
$MY_PATH/zen/ipns_TAG_refresh.sh
## REINIT dead swarm
## REINIT dead swarm STATIONS
rm -f ~/.zen/A_dead_swarm.txt
fi
##################################################################
##################################################################
# MIDNIGHT:01 : CLEANING & UPDATE
# 5 mn / 24h REBOOT & MIDNIGHT:01 : CLEANING & UPDATE
##################################################################
##################################################################
if [[ "$timebar" == "00:01" || "$runtime" == "5" || $(($runtime % 1380)) == 0 ]]; then
@ -250,8 +254,8 @@ echo '
# New full test review in gchange_INIT.sh
rm -f ~/.ipfs/test.disk
# LOG ROTATE
[[ -f /tmp/astroport.log ]] && tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log && echo "" > /tmp/astroport.log
# LOG ROTATE WEEKLY
[[ -f /tmp/astroport.log ]] && [[ ! -f ~/.zen/astroport.$weeknumber.log.tgz ]] && tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log && echo "" > /tmp/astroport.log
fi
@ -280,3 +284,4 @@ fi
# echo "1" > ~/.zen/ipfs/.$IPFSNODEID/.switch
#fi
#fi
## BETTER ACTIVATING DEFCON 3 / swarm.key MODE