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
|
|
|
|
2020-06-14 23:35:06 +02:00
|
|
|
source $HOME/.profile
|
2020-05-23 03:57:01 +02:00
|
|
|
# CORRECT PATH
|
|
|
|
[[ ! $(echo $PATH | grep "/usr/local/bin") ]] && export PATH="$PATH:/usr/local/bin"
|
2020-09-15 21:33:52 +02:00
|
|
|
[[ ! $(echo $PATH | grep "HOME/.local/bin") ]] && export PATH="$PATH:$HOME/.local/bin"
|
2020-05-23 03:57:01 +02:00
|
|
|
[[ ! $(echo $PATH | grep "/usr/games") ]] && export PATH="$PATH:/usr/games"
|
|
|
|
|
2020-06-13 13:30:51 +02:00
|
|
|
#### INIT STATION PARAMETERS
|
2020-12-08 01:47:34 +01:00
|
|
|
[[ -f $MY_PATH/../secret.astroport.key ]] && source $MY_PATH/../secret.astroport.key # DEPRECATED now using ~/.bashrc
|
2020-06-13 13:30:51 +02:00
|
|
|
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
|
2020-06-06 03:54:36 +02:00
|
|
|
source /home/$YOU/.profile
|
2020-06-13 13:30:51 +02:00
|
|
|
[[ $IPFSNODEID ]] && export IPFSNODEID=$IPFSNODEID || export IPFSNODEID=$(ipfs id -f='<id>\n')
|
2020-06-06 03:49:24 +02:00
|
|
|
|
2020-05-23 03:28:26 +02:00
|
|
|
########################################################################
|
|
|
|
# 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-11-30 19:21:30 +01:00
|
|
|
# WARNING: This script must be processing 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-11-30 19:21:30 +01:00
|
|
|
export isKodiRunning=$(ps auxf --sort=+utime | grep -w kodi | 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)
|
2020-12-05 00:10:19 +01:00
|
|
|
### DETECT FLAVOURS (TODO: Publish and share into ipfs/.12D3KooW***/ )
|
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
|
|
|
|
|
|
|
#
|
|
|
|
# _________
|
|
|
|
# / ____< /________ ___ _____
|
|
|
|
# / / __ / / ___/ __ `__ \/ ___/
|
|
|
|
#/ /_/ // (__ ) / / / / (__ )
|
|
|
|
#\____//_/____/_/ /_/ /_/____/
|
|
|
|
#
|
2020-11-30 21:01:40 +01:00
|
|
|
# $MY_PATH/g1sms/sms_ASTROPORT.sh
|
2020-05-28 17:55:06 +02:00
|
|
|
|
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
|
|
|
|
#######################################
|
2020-06-13 13:30:51 +02:00
|
|
|
sleep $((1 + RANDOM % 12))
|
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-11-30 21:01:40 +01:00
|
|
|
# REFRESH IPFS SWARM DATA EVERY 12 & 15 minutes
|
|
|
|
[[ $(($minute % 12)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/gchange_IPFS_swarm.sh &
|
2020-06-08 04:04:25 +02:00
|
|
|
[[ $(($minute % 15)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ipfs_SWARM_refresh.sh &
|
2020-11-30 21:01:40 +01:00
|
|
|
|
|
|
|
|
2020-06-06 12:47:12 +02:00
|
|
|
## TODO investigate could breaks "ipfs p2p" forwards ?
|
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-06-06 03:26:58 +02:00
|
|
|
##################################################################
|
2020-05-23 03:28:26 +02:00
|
|
|
##################################################################
|
|
|
|
# MIDNIGHT:01 : ZENBOT CLEANING & UPDATE
|
2020-06-06 03:26:58 +02:00
|
|
|
##################################################################
|
|
|
|
##################################################################
|
2020-05-23 03:28:26 +02:00
|
|
|
if [[ "$timebar" == "00:01" ]]; then
|
|
|
|
echo '
|
2020-05-13 23:27:29 +02:00
|
|
|
# ____ ____ ____ ___
|
|
|
|
# / __ \/ __ \ _ / __ < /
|
|
|
|
# / / / / / / / (_) / / / / /
|
|
|
|
# / /_/ / /_/ / _ / /_/ / /
|
|
|
|
# \____/\____/ (_) \____/_/
|
|
|
|
#
|
2020-12-08 01:47:34 +01:00
|
|
|
# MAINTENANCE
|
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-06-06 03:26:58 +02:00
|
|
|
##################################################################
|
|
|
|
# REFRESH & UPGRADE youtube-dl
|
2020-05-07 17:34:16 +02:00
|
|
|
youtube-dl --rm-cache-dir
|
|
|
|
youtube-dl -U
|
2020-06-06 03:26:58 +02:00
|
|
|
#### DESYNC
|
2020-05-23 03:40:03 +02:00
|
|
|
sleep $((1 + RANDOM % 5))
|
2020-06-06 03:26:58 +02:00
|
|
|
##################################################################
|
2020-06-06 05:22:18 +02:00
|
|
|
# ssb_INIT + LOG ROTATE EVERY SUNDAY # TODO /var/log/ + logrotate (& tempfiles in /tmp in RAMFS)
|
2020-06-08 04:04:25 +02:00
|
|
|
if [[ $dayoftheweek == 0 ]]; then
|
2020-11-30 21:01:40 +01:00
|
|
|
$MY_PATH/zen/gchange_INIT.sh &
|
2020-12-08 01:47:34 +01:00
|
|
|
# ACTIVATE IF CRON LOGGING
|
|
|
|
#tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log # LOG BACKUP FOR 1 YEAR !!
|
2020-06-08 04:04:25 +02:00
|
|
|
fi
|
2020-06-06 03:26:58 +02:00
|
|
|
#### DESYNC
|
2020-05-23 03:40:03 +02:00
|
|
|
sleep $((1 + RANDOM % 5))
|
2020-06-06 03:26:58 +02:00
|
|
|
##################################################################
|
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
|
2020-05-23 03:05:05 +02:00
|
|
|
|
2020-06-06 03:26:58 +02:00
|
|
|
##################################################################
|
2020-06-09 21:52:29 +02:00
|
|
|
|
2020-05-23 03:40:03 +02:00
|
|
|
echo '
|
|
|
|
_________ ______
|
|
|
|
____ ___ ____ /_ __/ | / ____/
|
|
|
|
/_ / / _ \/ __ \ / / / /| |/ / __
|
|
|
|
/ /_/ __/ / / / / / / ___ / /_/ /
|
|
|
|
/___/\___/_/ /_/ /_/ /_/ |_\____/
|
|
|
|
|
2020-12-08 01:47:34 +01:00
|
|
|
REFRESHing ZenTAG nano DHTs = Zen File ECONOMY
|
2020-05-23 03:40:03 +02:00
|
|
|
'
|
2020-12-08 01:47:34 +01:00
|
|
|
# ./zen/ipns_TAG_refresh.sh
|
2020-05-23 03:40:03 +02:00
|
|
|
|
2020-06-06 03:26:58 +02:00
|
|
|
##################################################################
|
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
|
|
|
|
2020-05-23 18:21:57 +02:00
|
|
|
fi
|
2020-06-06 03:26:58 +02:00
|
|
|
##################################################################
|
2020-05-23 18:21:57 +02:00
|
|
|
|
2020-05-18 03:58:04 +02:00
|
|
|
|
2020-05-07 17:34:16 +02:00
|
|
|
fi
|