2020-05-07 17:34:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
########################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
2020-05-10 23:58:08 +02:00
|
|
|
# Version: 0.3
|
2020-05-07 17:34:16 +02:00
|
|
|
# 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##*/}"
|
2020-05-23 03:57:01 +02:00
|
|
|
|
|
|
|
# CORRECT PATH
|
|
|
|
[[ ! $(echo $PATH | grep "/usr/local/bin") ]] && export PATH="$PATH:/usr/local/bin"
|
|
|
|
[[ ! $(echo $PATH | grep "~/.local/bin") ]] && export PATH="$PATH:~/.local/bin"
|
|
|
|
[[ ! $(echo $PATH | grep "/usr/games") ]] && export PATH="$PATH:/usr/games"
|
|
|
|
|
2020-05-18 03:58:04 +02:00
|
|
|
####
|
2020-05-23 03:28:26 +02:00
|
|
|
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
|
|
|
|
export IPFSNODEID=$(ipfs id -f='<id>\n') || er+=" ipfs id problem"
|
2020-06-03 02:09:46 +02:00
|
|
|
export WHOAMI=$($MY_PATH/zen/tools/timeout.sh -t 3 sbotc whoami | jq -r .id) || er+=" sbotc whoami problem"
|
2020-05-23 03:28:26 +02:00
|
|
|
[[ "$YOU" == "" || "$IPFSNODEID" == "" || "$WHOAMI" == "" ]] && echo "ERROR : $er " && exit 1
|
|
|
|
########################################################################
|
|
|
|
# HELP DEVLT: Search "TODO" in code
|
2020-05-18 03:58:04 +02:00
|
|
|
# Write what you thing about the situation
|
|
|
|
# AND how you would like to 'fix it'...
|
|
|
|
# Then friends can read and enhance solution.
|
2020-05-19 17:22:46 +02:00
|
|
|
# WARNING: This script must be precessing less than 1 minute, so do not charge too much this script
|
2020-05-10 23:58:08 +02:00
|
|
|
# _ _____ ____ _ _______ ________ ____
|
|
|
|
# | | / / | / __ \/ | / / _/ | / / ____/ / / /
|
|
|
|
# | | /| / / /| | / /_/ / |/ // // |/ / / __ / / /
|
|
|
|
# | |/ |/ / ___ |/ _, _/ /| // // /| / /_/ / /_/_/
|
|
|
|
# |__/|__/_/ |_/_/ |_/_/ |_/___/_/ |_/\____/ (_|_)
|
|
|
|
|
2020-05-18 03:58:04 +02:00
|
|
|
########################################################################
|
|
|
|
# NB: 'figlet' is used for labeling code trunks
|
2020-05-10 23:54:57 +02:00
|
|
|
########################################################################
|
|
|
|
### MODIFY WITH GREAT CARE!!! MUST BE BUG FREE !!!!!
|
2020-05-10 23:58:08 +02:00
|
|
|
### EVERY STATION RUN THIS SCRIPT EVERY MINUTE.
|
2020-05-13 23:27:29 +02:00
|
|
|
export isMinetestRunning=$(ps auxf --sort=+utime | grep -w minetest | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
|
|
|
|
export isG1smsRunning=$(ps auxf --sort=+utime | grep -w gammu | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
|
2020-05-18 03:58:04 +02:00
|
|
|
# ? isNextcloudRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
|
|
|
|
### DETECT FLAVOURS (TODO: Publish and share into ipfs/.Qm***/ )
|
2020-05-10 23:54:57 +02:00
|
|
|
########################################################################
|
2020-05-23 03:57:01 +02:00
|
|
|
cd $MY_PATH
|
2020-05-18 04:02:31 +02:00
|
|
|
|
2020-05-23 03:28:26 +02:00
|
|
|
# WHAT UNIVERSAL TIME is it ?
|
2020-05-07 17:34:16 +02:00
|
|
|
minute=$(date -u +%M)
|
|
|
|
heure=$(date -u +%H)
|
|
|
|
timebar="$heure:$minute"
|
2020-05-23 03:28:26 +02:00
|
|
|
dayoftheweek=$(date +%w)
|
|
|
|
dayofthemonth=$(date +%d)
|
|
|
|
weeknumber=$(date +%V)
|
2020-05-18 04:35:36 +02:00
|
|
|
|
|
|
|
echo $timebar
|
2020-05-28 17:55:06 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# _________
|
|
|
|
# / ____< /________ ___ _____
|
|
|
|
# / / __ / / ___/ __ `__ \/ ___/
|
|
|
|
#/ /_/ // (__ ) / / / / (__ )
|
|
|
|
#\____//_/____/_/ /_/ /_/____/
|
|
|
|
#
|
|
|
|
$MY_PATH/g1sms/sms_ASTROPORT.sh
|
|
|
|
|
2020-05-07 17:34:16 +02:00
|
|
|
# TIME NTP SYNC: TODO: Problem being root (stickybit INSTALL?)
|
2020-05-23 03:28:26 +02:00
|
|
|
# G1Tx. G1sms. G1Dab Zen economy needs precise time sync (RpiZero !!)
|
|
|
|
# Tx rates is limited by Station time synchronisation.
|
2020-05-07 17:34:16 +02:00
|
|
|
# sudo ntpdate ntp.pool.org
|
|
|
|
|
2020-05-13 23:27:29 +02:00
|
|
|
# ____ _______ __ __
|
|
|
|
# / __ \/ ____/ | / / ____ ___ ____ ____/ /__
|
|
|
|
# / / / / __/ | | / / / __ `__ \/ __ \/ __ / _ \
|
|
|
|
# / /_/ / /___ | |/ / / / / / / / /_/ / /_/ / __/
|
|
|
|
# /_____/_____/ |___/ /_/ /_/ /_/\____/\__,_/\___/
|
|
|
|
#
|
|
|
|
#
|
2020-05-07 17:34:16 +02:00
|
|
|
# ACTIVATE 5 MN "git pull" update
|
2020-05-21 02:11:38 +02:00
|
|
|
if [[ $(($minute % 5)) == 0 ]]; then
|
|
|
|
sleep $((1 + RANDOM % 12))
|
|
|
|
### Remove files being in .gitignore
|
2020-05-21 02:35:06 +02:00
|
|
|
# git checkout -- www/LOVELand/jukebox/prefs/collection.sq3
|
|
|
|
# git checkout -- www/LOVELand/jukebox/prefs/prefs.var
|
2020-05-21 02:11:38 +02:00
|
|
|
#######################################
|
|
|
|
git pull
|
|
|
|
fi
|
2020-05-07 17:34:16 +02:00
|
|
|
|
2020-05-13 23:27:29 +02:00
|
|
|
# __________ ____ __ ________ ___________
|
|
|
|
# / ___/ ___// __ ) \ \ / _/ __ \/ ____/ ___/
|
|
|
|
# \__ \\__ \/ __ | _____\ \ / // /_/ / /_ \__ \
|
|
|
|
# ___/ /__/ / /_/ / /_____/ / _/ // ____/ __/ ___/ /
|
|
|
|
# /____/____/_____/ /_/ /___/_/ /_/ /____/
|
|
|
|
#
|
|
|
|
# __ __ _____ ____
|
|
|
|
# __/ // /_/ ___/ ______ __________ ___ / __ \
|
|
|
|
# /_ _ __/\__ \ | /| / / __ `/ ___/ __ `__ \/ / / /
|
|
|
|
# /_ _ __/___/ / |/ |/ / /_/ / / / / / / / / /_/ /
|
|
|
|
# /_//_/ /____/|__/|__/\__,_/_/ /_/ /_/ /_/\____/
|
|
|
|
#
|
2020-05-07 17:34:16 +02:00
|
|
|
##################################################################
|
2020-05-23 03:05:05 +02:00
|
|
|
# REFRESH IPFS SWARM DATA EVERY 12 & 15 minutes
|
2020-05-07 17:34:16 +02:00
|
|
|
[[ $(($minute % 12)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ssb_IPFS_swarm.sh
|
2020-05-18 06:38:46 +02:00
|
|
|
[[ $(($minute % 15)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ipfs_SWARM_refresh.sh
|
2020-05-07 17:34:16 +02:00
|
|
|
##################################################################
|
|
|
|
|
2020-05-13 23:27:29 +02:00
|
|
|
# _________ _______ __ _ __
|
|
|
|
# / ____< / /_ __/ |/ / ____ ___ ____ ____ (_) /_____ _____
|
|
|
|
# / / __ / / / / | / / __ `__ \/ __ \/ __ \/ / __/ __ \/ ___/
|
|
|
|
# / /_/ // / / / / | / / / / / / /_/ / / / / / /_/ /_/ / /
|
|
|
|
# \____//_/ /_/ /_/|_| /_/ /_/ /_/\____/_/ /_/_/\__/\____/_/
|
|
|
|
#
|
2020-05-07 17:34:16 +02:00
|
|
|
##################################################################
|
|
|
|
# MONITOR INPUT TX (TODO: DEBUG)
|
|
|
|
# Activate later for DAB ZenTx Machines
|
|
|
|
# [[ $(($minute % 5)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/g1_MONITOR_zen.sh "5 minutes"
|
|
|
|
##################################################################
|
|
|
|
|
|
|
|
##################################################################
|
2020-05-13 23:27:29 +02:00
|
|
|
# __ __ __
|
|
|
|
# __/ // /_____ ___ ____ __ __/ /__ __
|
|
|
|
# /_ _ __/_ / / _ \/ __ \/ / / / __/ | / /
|
|
|
|
# /_ _ __/ / /_/ __/ / / / /_/ / /_ | |/ /
|
|
|
|
# /_//_/ /___/\___/_/ /_/\__, /\__/ |___/
|
|
|
|
# /____/
|
2020-05-18 03:58:04 +02:00
|
|
|
# SSB message 2 "youtube-dl" EXPERIMENTAL
|
|
|
|
# TODO : Run on BIG STATIONS (Control available Disk Space !!)
|
2020-05-07 17:34:16 +02:00
|
|
|
##################################################################
|
|
|
|
# RANDOMLY RUN SSB GET zenytv (avoid simultaneous run in swarm)
|
|
|
|
randh=$((1 + RANDOM % 24))
|
|
|
|
# [[ $(($heure % $randh)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ssb_GET_zenytv.sh
|
|
|
|
##################################################################
|
|
|
|
randh=$((1 + RANDOM % 24))
|
|
|
|
# [[ $(($heure % $randh)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ssb_GET_zenyta.sh
|
|
|
|
##################################################################
|
|
|
|
|
2020-05-23 03:28:26 +02:00
|
|
|
##################################################################
|
|
|
|
# MIDNIGHT:01 : ZENBOT CLEANING & UPDATE
|
|
|
|
if [[ "$timebar" == "00:01" ]]; then
|
|
|
|
echo '
|
2020-05-13 23:27:29 +02:00
|
|
|
# ____ ____ ____ ___
|
|
|
|
# / __ \/ __ \ _ / __ < /
|
|
|
|
# / / / / / / / (_) / / / / /
|
|
|
|
# / /_/ / /_/ / _ / /_/ / /
|
|
|
|
# \____/\____/ (_) \____/_/
|
|
|
|
#
|
2020-05-23 18:21:57 +02:00
|
|
|
# Clean & Upgrade + Log rotation + git pull + ipfs p2p port forward refresh
|
2020-05-23 03:28:26 +02:00
|
|
|
'
|
2020-05-23 03:40:03 +02:00
|
|
|
sleep $((1 + RANDOM % 5)) ### Be careful if random sleep is not activated...
|
2020-05-18 03:58:04 +02:00
|
|
|
############################## That swarm could become an aggressive blob !!
|
|
|
|
### PEACE & LOVE software is processing... We are HyperWeb people here.
|
2020-05-23 03:40:03 +02:00
|
|
|
# DEFCON 5 quiet behaviour so Please keep cool, take care and be zen.
|
|
|
|
# GOOD BYE GOOGLE, AMAZON, FACEBOOK, APPLE, MICROSOFT. We don't need you.
|
2020-05-18 03:58:04 +02:00
|
|
|
|
2020-05-07 17:34:16 +02:00
|
|
|
# UPGRADE youtube-dl
|
|
|
|
youtube-dl --rm-cache-dir
|
|
|
|
youtube-dl -U
|
|
|
|
|
2020-05-23 03:40:03 +02:00
|
|
|
sleep $((1 + RANDOM % 5))
|
2020-05-07 17:34:16 +02:00
|
|
|
# LOG ROTATE EVERY SUNDAY
|
2020-05-23 03:28:26 +02:00
|
|
|
[[ $dayoftheweek == 0 ]] && mv -f /tmp/astroport.log ~/.zen/astroport.$weeknumber.log # LOG BACKUP FOR 1 YEAR !!
|
2020-05-07 17:34:16 +02:00
|
|
|
|
2020-05-23 03:40:03 +02:00
|
|
|
sleep $((1 + RANDOM % 5))
|
2020-05-21 02:11:38 +02:00
|
|
|
|
|
|
|
# GIT UPDATE
|
|
|
|
./git-update.sh
|
2020-05-07 17:34:16 +02:00
|
|
|
git pull # UPDATE CODE git pull
|
|
|
|
|
|
|
|
# Clear 24h ssb_GET markers
|
|
|
|
rm ~/.zen/zenytv.last.ts
|
|
|
|
rm ~/.zen/zenyta.last.ts
|
|
|
|
|
2020-05-23 03:05:05 +02:00
|
|
|
echo '
|
|
|
|
_________
|
|
|
|
/ ____< / _________ ___ _____
|
|
|
|
/ / __ / / / ___/ __ `__ \/ ___/
|
|
|
|
/ /_/ // / (__ ) / / / / (__ )
|
|
|
|
\____//_/ /____/_/ /_/ /_/____/
|
|
|
|
|
2020-05-23 03:28:26 +02:00
|
|
|
forwarding to http://127.0.0.1:10099
|
2020-05-23 03:05:05 +02:00
|
|
|
'
|
|
|
|
ipfs p2p close --all
|
2020-05-23 03:28:26 +02:00
|
|
|
./zen/ipfs_OPEN_ports.sh
|
2020-05-23 03:05:05 +02:00
|
|
|
ipfs p2p ls
|
2020-05-07 17:34:16 +02:00
|
|
|
|
2020-05-23 03:40:03 +02:00
|
|
|
echo '
|
|
|
|
_________ ______
|
|
|
|
____ ___ ____ /_ __/ | / ____/
|
|
|
|
/_ / / _ \/ __ \ / / / /| |/ / __
|
|
|
|
/ /_/ __/ / / / / / / ___ / /_/ /
|
|
|
|
/___/\___/_/ /_/ /_/ /_/ |_\____/
|
|
|
|
|
2020-05-23 18:21:57 +02:00
|
|
|
REFRESHing ZenTAG nano DHTs
|
2020-05-23 03:40:03 +02:00
|
|
|
'
|
|
|
|
./zen/ipns_TAG_refresh.sh
|
|
|
|
|
|
|
|
|
2020-05-23 18:21:57 +02:00
|
|
|
if [[ $dayofthemonth == 7 ]]; then
|
|
|
|
availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}')
|
|
|
|
diskSize="$((availableDiskSize / 2))"
|
|
|
|
ipfs config Datastore.StorageMax $diskSize
|
|
|
|
echo '
|
|
|
|
_____ __ __ ___
|
|
|
|
/ ___// /_____ _________ _____ ____ / |/ /___ __ __
|
|
|
|
\__ \/ __/ __ \/ ___/ __ `/ __ `/ _ \ / /|_/ / __ `/ |/_/
|
|
|
|
___/ / /_/ /_/ / / / /_/ / /_/ / __/ / / / / /_/ /> <
|
|
|
|
/____/\__/\____/_/ \__,_/\__, /\___/ /_/ /_/\__,_/_/|_|
|
|
|
|
/____/
|
2020-05-18 03:58:04 +02:00
|
|
|
# 1/2 HDD for IPFS size - dicotomic adaptation 7th EVERY MONTH
|
|
|
|
#
|
|
|
|
# TODO: Read parameters from ipfs, publish status to swarm, could be use for youtube-dl or other kind of heavy ipfs input Station election.
|
2020-05-13 23:27:29 +02:00
|
|
|
#
|
2020-05-23 18:21:57 +02:00
|
|
|
'
|
|
|
|
echo "StorageMax = $diskSize"
|
2020-05-27 17:44:38 +02:00
|
|
|
|
|
|
|
## RESET ipfs_SWARM_refresh.sh alert
|
|
|
|
rm -f /tmp/ssb-friends_ALERT.txt
|
|
|
|
|
2020-05-23 18:21:57 +02:00
|
|
|
fi
|
|
|
|
|
2020-05-18 03:58:04 +02:00
|
|
|
|
2020-05-07 17:34:16 +02:00
|
|
|
fi
|