2020-12-12 01:26:39 +01:00
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
2020-12-24 15:49:41 +01:00
# Armust Blegde release
2020-12-12 01:26:39 +01:00
# Version: 0.3
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
2021-03-18 01:27:22 +01:00
# REGULATEUR DES PULSATIONS DE L'AUTOMATE # CADENCE # 1/60 Hz
2021-05-23 04:47:18 +02:00
# INJECTEZ VOS ACTIONS DANS LES CYCLES...
2021-03-18 01:27:22 +01:00
########################################################################
2020-12-12 01:26:39 +01:00
MY_PATH = " `dirname \" $0 \"` " # relative
MY_PATH = " `( cd \" $MY_PATH \" && pwd )` " # absolutized and normalized
ME = " ${ 0 ##*/ } "
source $HOME /.profile
# CORRECT PATH
[ [ ! $( echo $PATH | grep "/usr/local/bin" ) ] ] && export PATH = " $PATH :/usr/local/bin "
2021-02-13 15:38:14 +01:00
[ [ ! $( echo $PATH | grep " $HOME /.local/bin " ) ] ] && export PATH = " $PATH : $HOME /.local/bin "
2020-12-12 01:26:39 +01:00
[ [ ! $( echo $PATH | grep "/usr/games" ) ] ] && export PATH = " $PATH :/usr/games "
2021-07-09 16:31:11 +02:00
#### CONTROL STATION IPFS DAEMON
2021-08-06 00:10:11 +02:00
## timeout is fixing ipfs minimum response time, before considering stuck process
2022-05-28 03:05:51 +02:00
IPFSNODEID = $( ipfs id --timeout= 1s | jq -r .ID)
2021-09-22 23:35:37 +02:00
howmany = $( cat /tmp/ipfs.timeout)
if [ [ ! $IPFSNODEID ] ] ; then
## wait a howmany timeout before restarting ipfs
howmany = $(( howmany + 1 )) && echo $howmany > /tmp/ipfs.timeout
2021-09-25 02:09:30 +02:00
[ $howmany -gt 3 ] && [ [ " ${ USER } " = = "xbian" ] ] && echo "IPFS NOT RUNNING" && rm /tmp/ipfs.timeout && rm /config/ipfs/repo.lock && sudo service ipfs restart && exit 1
[ $howmany -gt 3 ] && [ [ -f /etc/sudoers.d/systemctl ] ] && echo " IPFS NOT RUNNING $( date) " && rm /tmp/ipfs.timeout && rm /config/ipfs/repo.lock && sudo systemctl restart ipfs
rm ~/.zen/restart.txt
2021-09-22 23:35:37 +02:00
exit 1
else
echo 0 > /tmp/ipfs.timeout
fi
2021-09-22 23:38:04 +02:00
2021-07-06 22:45:51 +02:00
## CONTROL IPFS IS RUNNING OR RESTART
2021-07-09 23:36:20 +02:00
YOU = $( ps auxf --sort= +utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
if [ [ ! ${ YOU } ] ] ; then
2022-05-14 15:56:55 +02:00
# Refresh Peering.Peers
ipfs config --json Peering.Peers '[]'
# DHT PUBSUB mode
ipfs config Pubsub.Router gossipsub
# MAXSTORAGE = 1/2 available
availableDiskSize = $( df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}' )
diskSize = " $(( availableDiskSize / 2 )) "
ipfs config Datastore.StorageMax $diskSize
## Activate Rapid "ipfs p2p"
ipfs config --json Experimental.Libp2pStreamMounting true
ipfs config --json Experimental.P2pHttpProxy true
2021-09-22 23:38:04 +02:00
# control water levels for swarm
2021-09-11 01:35:24 +02:00
ipfs config --json Swarm.ConnMgr.LowWater 50
ipfs config --json Swarm.ConnMgr.HighWater 100
2022-05-14 15:56:55 +02:00
2021-09-22 23:38:04 +02:00
[ $howmany -gt 3 ] && [ [ " ${ USER } " = = "xbian" ] ] && sudo service ipfs restart || sudo systemctl restart ipfs
2021-07-06 22:45:51 +02:00
echo "ERROR! ipfs daemon was not running. RELAUNCHING."
exit 1
fi
2021-03-06 13:30:40 +01:00
########################################################################
2022-05-14 15:56:55 +02:00
# CORRECT VSTREAM ASTROPORT SITE/ART REMOVED AFTER PLUGIN UPDATE : TODO DEBUG KODI PLUGIN !!!
2021-02-20 02:01:58 +01:00
[ [ ! -f ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py ] ] && [ [ -f ~/.zen/astroport.py ] ] && cp -f ~/.zen/astroport.py ~/.kodi/addons/plugin.video.vstream/resources/sites/
2021-09-11 01:35:24 +02:00
[ [ ! -f ~/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ] ] && cp ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ~/.kodi/addons/plugin.video.vstream/resources/art/ 2>/dev/null
2021-03-06 13:30:40 +01:00
########################################################################
2021-02-20 02:01:58 +01:00
2022-05-14 15:56:55 +02:00
### NO IP GATEWAY : EXIT (COULD BE Astroport.ONE Ambassy Alone !!)
2021-05-19 15:24:22 +02:00
ping -q -w 1 -c 1 ` ip r | grep default | cut -d ' ' -f 3` 2>& 1>/dev/null && echo "LAN OK" || exit 1
2021-02-18 11:02:42 +01:00
2021-03-06 21:18:14 +01:00
########################################################################
### TEMP CODE (add missing packages to xbian) - TODO REMOVE after 30 mn for git pull & apply
# [[ $(which ffmpeg) == "" && "$USER" == "xbian" ]] && sudo apt-get update && sudo apt-get install git fail2ban inotify-tools curl net-tools libsodium* python3-dev python3-pip python3-setuptools python3-wheel mpack libssl-dev libffi-dev build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils vlc mp3info x11-utils -y
2021-03-17 16:54:15 +01:00
2021-03-06 21:18:14 +01:00
########################################################################
2020-12-12 01:26:39 +01:00
########################################################################
# HELP DEVLT: Search "TODO" in code
# WARNING: This script must be processing less than 1 minute, so do not charge too much this script
# _ _____ ____ _ _______ ________ ____
# | | / / | / __ \/ | / / _/ | / / ____/ / / /
2021-08-01 20:44:29 +02:00
# | | /| / / /| | / /_/ / |/ // // |/ / / __ / / /
# | |/ |/ / ___ |/ _, _/ /| // // /| / /_/ / /_/_/
# |__/|__/_/ |_/_/ |_/_/ |_/___/_/ |_/\____/ (_|_)
2020-12-12 01:26:39 +01:00
########################################################################
2021-01-31 23:18:56 +01:00
# 'figlet' was used for labeling code trunks
2020-12-12 01:26:39 +01:00
########################################################################
### MODIFY WITH GREAT CARE!!! MUST BE BUG FREE !!!!!
### EVERY STATION RUN THIS SCRIPT EVERY MINUTE.
export isKodiRunning = $( ps auxf --sort= +utime | grep -w kodi | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
########################################################################
cd $MY_PATH
2021-03-30 01:17:26 +02:00
########################################################################
# WHAT TIME(s) is it ?
timestamp = " $( date -u +%s%N | cut -b1-13) "
2020-12-12 01:26:39 +01:00
minute = $( date -u +%M)
heure = $( date -u +%H)
timebar = " $heure : $minute "
dayoftheweek = $( date +%w)
dayofthemonth = $( date +%d)
weeknumber = $( date +%V)
2021-03-30 01:17:26 +02:00
# WAKEUP TIME
2021-09-04 16:25:46 +02:00
if [ [ ! -f /tmp/A_Station_ON ] ] ; then
echo " onheure= $heure ; onminute= $minute ; ontimebar= $timebar " > /tmp/A_Station_ON
2021-03-30 01:17:26 +02:00
else
2021-09-04 16:25:46 +02:00
source /tmp/A_Station_ON
2021-06-04 01:44:36 +02:00
old = $ontimebar
new = $timebar
# feeding variables by using read and splitting with IFS
IFS = : read old_hour old_min <<< " $old "
IFS = : read hour min <<< " $new "
# convert hours to minutes
# the 10# is there to avoid errors with leading zeros
# by telling bash that we use base 10
total_old_minutes = $(( 10# $old_hour * 60 + 10# $old_min ))
total_minutes = $(( 10# $hour * 60 + 10# $min ))
runtime = $(( total_minutes - total_old_minutes))
2021-08-06 00:30:58 +02:00
runtime = ${ runtime #- }
2021-03-30 01:17:26 +02:00
fi
# RUN TIME $runtime
2021-05-23 02:48:11 +02:00
echo " RUNTIME $runtime mn ( $timebar ) "
2021-08-05 23:57:29 +02:00
2021-08-06 00:36:11 +02:00
2021-09-13 03:20:42 +02:00
if [ [ $(( $runtime % 4 )) = = 0 ] ] ; then
2021-08-06 00:36:11 +02:00
## PING ALL MY FRIENDS TO ENHANCE SWARM CONNECTIVITY
echo "## FRIENDS IPFS PINGing"
2021-09-12 00:35:16 +02:00
for g1pub in $( ls -t ~/.zen/ipfs/.$IPFSNODEID /FRIENDS/) ; do
2021-09-23 01:01:57 +02:00
[ [ $g1pub ] ] && latency = $( ipfs ping --timeout= 1s -n 1 /p2p/$( ~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null | grep "Average" | cut -d ':' -f 2) ;
2021-09-12 00:35:16 +02:00
[ [ $latency ] ] && echo $latency > ~/.zen/ipfs/.$IPFSNODEID /FRIENDS/$g1pub /ping.average.txt
2021-09-23 02:14:19 +02:00
## AVERAGE PING cat ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/*/ping.average.txt
2022-05-14 15:56:55 +02:00
# for line in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/*/ping.average.txt); do g1friend=$(echo $line | cut -d '/' -f 8); ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1friend); cat ~/.zen/ipfs_swarm/.$ipfsnodeid/.player; cat $line; done
2021-09-12 00:35:16 +02:00
done
2021-08-06 00:36:11 +02:00
fi
2021-06-16 01:21:56 +02:00
########################################################################
2021-06-16 01:06:01 +02:00
## CHECK & (RE)ACTIVATE ipfs p2p tunnels
2021-06-16 01:21:56 +02:00
########################################################################
2021-06-16 01:06:01 +02:00
# NextCloud FROM taurus TO oasis (https://taurus.copylaradio.com)
~/.zen/astrXbian/zen/ipfs_P2P_forward.sh
2021-06-16 01:21:56 +02:00
########## 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
2021-06-16 01:06:01 +02:00
2021-06-16 01:21:56 +02:00
########################################################################
# DEFCON
2021-03-30 01:17:26 +02:00
########################################################################
2021-08-01 20:44:29 +02:00
# STATION CAN MODIFY DEFCON (cool 5 to 1 war) - only 5 and 4 (fail2ban) are ready to use.
2021-02-21 20:33:38 +01:00
[ [ -f ~/.zen/DEFCON ] ] && export DEFCON = $( cat ~/.zen/DEFCON) || export DEFCON = $( cat ~/.zen/astrXbian/DEFCON) # ADAPT $DEFCON scenario
2021-05-23 02:48:11 +02:00
## DEFCON SYSTEM ACTIVATED
2021-01-31 23:18:56 +01:00
2021-08-01 20:44:29 +02:00
# _ ____
# / | | ___| _ __ ___ _ __
# | | |___ \ | '_ ` _ \| '_ \
2021-07-09 16:31:11 +02:00
# | | ___) | | | | | | | | | |
# |_| |____/ |_| |_| |_|_| |_|
2021-08-01 20:44:29 +02:00
#
2021-07-09 16:31:11 +02:00
2021-05-23 02:48:11 +02:00
########################################################################
2021-06-16 01:21:56 +02:00
# SMARM MAINTENANCE / 15 mn
2021-05-23 02:48:11 +02:00
########################################################################
2021-06-16 01:21:56 +02:00
# astrXbian TestNET (git pull) -> desactivate in release ipfs get codeID
2021-05-23 02:48:11 +02:00
########################################################################
2021-08-06 00:10:11 +02:00
# ACTIVATE 15 MN "git pull" update
if [ [ $(( $runtime % 15 )) = = 0 ] ] ; then
2021-07-09 16:31:11 +02:00
2021-02-13 14:25:50 +01:00
########## DESYNCH SWARM NODE REQUESTS #################
2021-03-18 00:46:55 +01:00
# git reset --hard
git pull
2021-05-19 15:24:22 +02:00
[ [ ! $? = = 0 ] ] && echo "GIT.P2P.LEGAL IS UNREACHABLE"
2021-03-28 21:04:55 +02:00
# if [[ $(diff ~/.zen/astrXbian/.install/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml ~/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml) ]]; then
2021-06-04 01:44:36 +02:00
# cp ~/.zen/astrXbian/.install/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml ~/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml
# echo "MAJ Vstream settings"
# fi
2021-05-17 05:11:12 +02:00
2021-08-01 20:44:29 +02:00
## IN CASE OF jaklis UPGRADE ACTIVATE AND REMOVE
## cd ~/.zen/astrXbian/zen/jaklis; ./setup.sh; cd -
2021-07-01 01:35:11 +02:00
2022-05-14 15:56:55 +02:00
# CLEAN AND REMOVE BAD DIRECTORIES should be in .$IPFSNODEID to avoid Station collision.
2021-06-16 01:21:56 +02:00
## BYPASS index.html DELETION
2021-06-04 01:44:36 +02:00
[ [ -f ~/.zen/ipfs/index.html ] ] && cp ~/.zen/ipfs/index.html /tmp/ipfsindex.html
2021-08-01 20:44:29 +02:00
2021-06-04 01:44:36 +02:00
[ [ -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
2021-06-16 01:21:56 +02:00
## CLEANING PARASITE BAD FILES
2021-08-04 03:44:55 +02:00
rm -Rf ~/.zen/ipfs/*
2021-06-04 01:44:36 +02:00
rm ~/.zen/ipfs/.*
2021-08-04 03:44:55 +02:00
rm -Rf ~/.zen/ipfs_swarm/*
2021-06-04 01:44:36 +02:00
rm ~/.zen/ipfs_swarm/.*
2021-08-01 20:44:29 +02:00
2021-06-16 01:21:56 +02:00
## RESTORE index.html from /tmp/ipfsindex.html
2021-06-04 01:44:36 +02:00
[ [ -f /tmp/ipfsindex.html ] ] && mv /tmp/ipfsindex.html ~/.zen/ipfs/index.html
2021-05-19 15:24:22 +02:00
2020-12-12 01:26:39 +01:00
fi
2021-08-01 20:44:29 +02:00
# __ __ _____ ____
2020-12-12 01:26:39 +01:00
# __/ // /_/ ___/ ______ __________ ___ / __ \
# /_ _ __/\__ \ | /| / / __ `/ ___/ __ `__ \/ / / /
2021-08-01 20:44:29 +02:00
# /_ _ __/___/ / |/ |/ / /_/ / / / / / / / / /_/ /
2021-03-30 01:17:26 +02:00
# /_//_/ /____/|__/|__/\__,_/_/ /_/ /_/ /_/\____/ gchange sync
2021-08-01 20:44:29 +02:00
#
2020-12-12 01:26:39 +01:00
##################################################################
2021-04-07 23:01:20 +02:00
# TODO: IDEA make gchange/ipfs/ipns refresh speed depending on ipfs swarm size and DEFCON level !
2021-09-12 18:18:46 +02:00
## SYNC GCHANGE EVERY 12 hours runtime
2021-09-21 01:38:38 +02:00
if [ [ $(( $runtime % 725 )) = = 0 || " $runtime " = = "5" ] ] ; then
kill -9 $( ps auxf --sort= +utime | grep -w gchange_INIT.sh | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}' ) && echo "KILLING gchange_INIT.sh"
$MY_PATH /zen/gchange_INIT.sh 2>& 1 > /home/${ YOU } /.zen/ipfs/.${ IPFSNODEID } /.log.gchange_INIT.txt
fi
2021-09-23 02:40:52 +02:00
# If NEW ~/.ipfs/config.new => restarting IPFS daemon (not too often as 6h)
if [ [ -f ~/.ipfs/config.new && $( diff ~/.ipfs/config.new ~/.ipfs/config) && $runtime -gt 360 ] ] ; then
echo " onheure= $heure ; onminute= $minute ; ontimebar= $timebar " > /tmp/A_Station_ON
2021-09-19 00:23:37 +02:00
cp ~/.ipfs/config.new ~/.ipfs/config
[ [ -f /etc/sudoers.d/systemctl ] ] && sudo systemctl restart ipfs && exit 0
[ [ ${ YOU } = = "xbian" ] ] && sudo service ipfs restart && exit 0
fi
## RESHAPE IPFS FRIENDS SWARM
2021-09-21 01:38:38 +02:00
if [ [ $(( $runtime % 370 )) = = 0 || " $runtime " = = "10" ] ] ; then
kill -9 $( ps auxf --sort= +utime | grep -w gchange_IPFS_swarm.sh | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}' ) && echo "KILLING gchange_IPFS_swarm.sh"
$MY_PATH /zen/gchange_IPFS_swarm.sh 2>& 1 > /home/${ YOU } /.zen/ipfs/.${ IPFSNODEID } /.log.gchange_IPFS_swarm.txt
fi
2021-09-19 00:23:37 +02:00
# SYNC IPFS FRIENDS SWARM
2022-05-14 15:56:55 +02:00
if [ [ $(( $runtime % 26 )) = = 0 ] ] ; then
kill -9 $( ps auxf --sort= +utime | grep -w ipfs_SWARM_refresh.sh | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}' ) && echo "KILLING ipfs_SWARM_refresh.sh"
2021-09-13 18:10:35 +02:00
killall chromium
$MY_PATH /zen/ipfs_SWARM_refresh.sh 2>& 1 > /home/${ YOU } /.zen/ipfs/.${ IPFSNODEID } /.log.ipfs_SWARM_refresh.txt
fi
2021-09-19 02:19:01 +02:00
##################################################################
#
# _________ ______
# ____ ___ ____ /_ __/ | / ____/
# /_ / / _ \/ __ \ / / / /| |/ / __
# / /_/ __/ / / / / / / ___ / /_/ /
# /___/\___/_/ /_/ /_/ /_/ |_\____/
#
# REFRESHing MEDIAKEY / ZenTAG nano DHTs => Zen File ECONOMY wallet cycle
2022-05-14 15:56:55 +02:00
### IMPORTANT !!!!!!! IMPORTANT !!!!!! Maintains MEDIAKEY alive
################################################
2021-09-19 02:19:01 +02:00
if [ [ $(( $runtime % 7 )) = = 0 ] ] ; then
#### Refresh & publish MEDIAKEYs
$MY_PATH /zen/ipns_TAG_refresh.sh > /home/${ YOU } /.zen/ipfs/.${ IPFSNODEID } /.log.ipns_TAG_refresh.txt
## REINIT dead swarm STATIONS
rm -f ~/.zen/A_dead_swarm.txt
fi
2021-08-11 00:08:27 +02:00
## TODO ACTIVATE/DESACTIVATE LOG
2021-06-16 01:21:56 +02:00
########################################################################
# ACTIVATE ~/astroport directory monitoring (xbian only)
########################################################################
2021-05-23 02:48:11 +02:00
###
2021-08-01 20:44:29 +02:00
# _ _
# __ _| |__ (_) __ _ _ __
# \ \/ / '_ \| |/ _` | '_ \
2020-12-15 23:23:36 +01:00
# > <| |_) | | (_| | | | |
2021-03-18 00:18:48 +01:00
# /_/\_\_.__/|_|\__,_|_| |_| inotifywait
2021-08-01 20:44:29 +02:00
#
# ON Rpi/xbian files added in ~/astroport are monitored to activate "new_file_in_astroport.sh"
2021-03-06 20:00:25 +01:00
# Transfert ~/astroport/*/files to IPFS and make Astroport/KODI indexes in IPNS
2022-05-14 15:56:55 +02:00
## TEST AUTOMATIC NEW FILE IMPORT. xbian only.
2021-05-19 15:14:09 +02:00
if [ [ " $USER " = = "xbian" ] ] ; then
2021-06-16 01:21:56 +02:00
[ [ ! -e $HOME /astroport ] ] && mkdir -p $HOME /astroport
2021-06-04 01:44:36 +02:00
# 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" ] ]
then
/usr/bin/inotifywait -r -e close_write -m /home/$USER /astroport | while read dir flags file; do $MY_PATH /zen/new_file_in_astroport.sh " $dir " " $file " ; done >> /tmp/astroport.inotify.log 2>& 1 &
fi
2020-12-12 01:26:39 +01:00
fi
2021-03-06 20:00:25 +01:00
2021-03-18 00:18:48 +01:00
##########################################################
2020-12-12 01:26:39 +01:00
2021-03-01 02:25:02 +01:00
2020-12-12 01:26:39 +01:00
##################################################################
##################################################################
2021-06-16 01:21:56 +02:00
# 5 mn / 24h REBOOT & MIDNIGHT:01 : CLEANING & UPDATE
2020-12-12 01:26:39 +01:00
##################################################################
##################################################################
2021-09-06 01:07:59 +02:00
if [ [ " $timebar " = = "00:01" || " $runtime " = = "30" || $(( $runtime % 1380 )) = = 0 ] ] ; then
2020-12-12 01:26:39 +01:00
echo '
# ____ ____ ____ ___
# / __ \/ __ \ _ / __ < /
2021-08-01 20:44:29 +02:00
# / / / / / / / (_) / / / / /
# / /_/ / /_/ / _ / /_/ / /
# \____/\____/ (_) \____/_/
#
2020-12-12 01:26:39 +01:00
# MAINTENANCE
'
2021-08-06 00:10:11 +02:00
sleep $(( 1 + RANDOM % 12 )) ### Be careful if random sleep is not activated...
2020-12-12 01:26:39 +01:00
############################## That swarm could become an aggressive blob !!
### PEACE & LOVE software is processing... We are HyperWeb people here.
# DEFCON 5 quiet behaviour so Please keep cool, take care and be zen.
2021-01-31 23:18:56 +01:00
# GOOD BYE GOOGLE, AMAZON, FACEBOOK, APPLE, MICROSOFT. LIBRE WE ARE.
2021-06-04 01:44:36 +02:00
####################################################################
2020-12-12 01:26:39 +01:00
# REFRESH & UPGRADE youtube-dl
2022-04-22 13:11:11 +02:00
$MY_PATH /.install/youtube-dl.sh ## LET IT A WHILE FOR ALL SWARM EXECUTE ACTION... AND REMOVE.
2021-06-04 01:44:36 +02:00
youtube-dl --rm-cache-dir
youtube-dl -U
2021-08-01 20:44:29 +02:00
2021-09-21 01:10:34 +02:00
### INDEX DATA MIGRATION SCRIPTS
2022-04-22 13:11:11 +02:00
# $MY_PATH/actions/p4n.data_evolution.sh &
2021-09-21 01:10:34 +02:00
## LET IT A WHILE FOR ALL SWARM EXECUTE ACTION... AND REMOVE.
2021-06-04 01:44:36 +02:00
##################################################################
2021-04-07 23:01:20 +02:00
if [ [ $dayoftheweek = = 1 ] ] ; then
2021-06-04 01:44:36 +02:00
# EVERY MONDAY
2021-08-01 20:44:29 +02:00
# _____ __ __ ___
2021-06-04 01:44:36 +02:00
# / ___// /_____ _________ _____ ____ / |/ /___ __ __
# \__ \/ __/ __ \/ ___/ __ `/ __ `/ _ \ / /|_/ / __ `/ |/_/
2021-08-01 20:44:29 +02:00
# ___/ / /_/ /_/ / / / /_/ / /_/ / __/ / / / / /_/ /> <
# /____/\__/\____/_/ \__,_/\__, /\___/ /_/ /_/\__,_/_/|_|
# /____/
2021-06-04 01:44:36 +02:00
# 1/2 HDD for IPFS size - dicotomic adaptation 7th EVERY MONTH
availableDiskSize = $( df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}' )
availableDiskSize = " $(( $availableDiskSize * 1024 )) "
2021-04-03 23:18:58 +02:00
2021-06-04 01:44:36 +02:00
diskSize = " $(( availableDiskSize / 2 )) "
ipfs config Datastore.StorageMax $diskSize
echo " StorageMax = $diskSize "
2021-08-01 20:44:29 +02:00
2021-06-04 01:44:36 +02:00
# New full test review in gchange_INIT.sh
2021-03-18 00:18:48 +01:00
rm -f ~/.ipfs/test.disk
2021-08-01 20:44:29 +02:00
2021-06-16 01:21:56 +02:00
# 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
2021-08-01 20:44:29 +02:00
2021-06-04 01:44:36 +02:00
fi
2021-08-01 20:44:29 +02:00
2021-06-04 01:44:36 +02:00
##################################################################
## CHECK STARTGATE LEVEL KEYS
2021-08-01 20:44:29 +02:00
# _ open _
# ___| |_ __ _ _ __ __ _ __ _| |_ ___
2021-06-04 01:44:36 +02:00
#/ __| __/ _` | '__/ _` |/ _` | __/ _ \
#\__ \ || (_| | | | (_| | (_| | || __/
#|___/\__\__,_|_| \__, |\__,_|\__\___|
2021-08-01 20:44:29 +02:00
# |___/
2021-06-04 01:44:36 +02:00
# IPNS KEYS used to publish with star friends (creates 5 levels of streaming / file sharing)
2021-08-01 20:44:29 +02:00
# RESET
2021-06-04 01:44:36 +02:00
ipfs key rm star_1; ipfs key rm star_2; ipfs key rm star_3; ipfs key rm star_4; ipfs key rm star_5
rm -Rf ~/.zen/key/
# RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh
$MY_PATH /zen/manage_stargates.sh
2020-12-12 01:26:39 +01:00
2021-09-04 02:17:41 +02:00
########################################################################
# ACTIVATE TO CONTROL SWARM STATION SAME CODE VERSION
########################################################################
## myCODE is a SECURITY about code SIMILARITY
## EACH NODE CAN CHECK IF ANOTHER HAS SAME IPFS CODE HASH
MyCODE = $( ipfs add -rq --ignore= "__pycache__" ~/.zen/astrXbian/ | tail -n 1)
[ [ ! -f ~/.zen/ipfs/.${ IPFSNODEID } /.mycode ] ] && echo $MyCODE > ~/.zen/ipfs/.${ IPFSNODEID } /.mycode
[ [ " $( cat ~/.zen/ipfs/.${ IPFSNODEID } /.mycode) " != " $MyCODE " ] ] && echo $MyCODE > ~/.zen/ipfs/.${ IPFSNODEID } /.mycode
echo " MyCODE = $MyCODE CODE is ready to be published "
########################################################################
# MEAN CONTROL SWARM STATION HAVE SAME CODE VERSION
########################################################################
2020-12-12 01:26:39 +01:00
fi
2021-05-17 05:10:03 +02:00
2021-05-23 02:48:11 +02:00
### DISAPEAR ONE HOUR FROM IPFS SWARM ZOMBIES > 300 peers in swarm
2021-08-01 20:44:29 +02:00
#if [[ $(cat /tmp/ipfs_swarm_peers | wc -l) -gt 300 ]]; then
2021-06-05 13:41:16 +02:00
#if [[ "$timebar" == "04:05" ]]; then
# ~/.zen/astrXbian/zen/ipfs_SWARM_renew.sh 3600 ## CUT IPFS FOR ONE HOUR
2021-06-04 01:44:36 +02:00
## SWITCHING ON
2021-06-05 13:41:16 +02:00
# echo "1" > ~/.zen/ipfs/.$IPFSNODEID/.switch
#fi
#fi
2021-06-16 01:21:56 +02:00
## BETTER ACTIVATING DEFCON 3 / swarm.key MODE