forked from axiom-team/astrXbian
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
188 lines
8.3 KiB
188 lines
8.3 KiB
#!/bin/bash |
|
######################################################################## |
|
# Author: Fred (support@qo-op.com) |
|
# Armust Blegde release |
|
# Version: 0.3 |
|
# 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##*/}" |
|
|
|
source $HOME/.profile |
|
# CORRECT PATH |
|
[[ ! $(echo $PATH | grep "/usr/local/bin") ]] && export PATH="$PATH:/usr/local/bin" |
|
[[ ! $(echo $PATH | grep "$HOME/.local/bin") ]] && export PATH="$PATH:$HOME/.local/bin" |
|
[[ ! $(echo $PATH | grep "/usr/games") ]] && export PATH="$PATH:/usr/games" |
|
|
|
#### INIT STATION PARAMETERS |
|
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) |
|
[[ $IPFSNODEID ]] && export IPFSNODEID=$IPFSNODEID || export IPFSNODEID=$(ipfs id -f='<id>\n') |
|
|
|
##################################################### |
|
# CORRECT VSTREAM ASTROPORT SITE REMOVAL AFTER UPDATE |
|
[[ ! -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/ |
|
##################################################### |
|
|
|
### NO IP GATEWAY : EXIT |
|
ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` 2> /dev/null && echo "OK" > /dev/null || (echo "NO GATEWAY CONNEXION" && exit 1) |
|
|
|
######################################################################## |
|
# HELP DEVLT: Search "TODO" in code |
|
# Write what you thing about the situation |
|
# AND how you would like to 'fix it'... |
|
# Then friends can read and enhance solution. |
|
# WARNING: This script must be processing less than 1 minute, so do not charge too much this script |
|
# _ _____ ____ _ _______ ________ ____ |
|
# | | / / | / __ \/ | / / _/ | / / ____/ / / / |
|
# | | /| / / /| | / /_/ / |/ // // |/ / / __ / / / |
|
# | |/ |/ / ___ |/ _, _/ /| // // /| / /_/ / /_/_/ |
|
# |__/|__/_/ |_/_/ |_/_/ |_/___/_/ |_/\____/ (_|_) |
|
|
|
######################################################################## |
|
# 'figlet' was used for labeling code trunks |
|
######################################################################## |
|
### 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) |
|
export isinotifywaitRunning=$(ps auxf --sort=+utime | grep -w inotifywait | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1) |
|
######################################################################## |
|
cd $MY_PATH |
|
|
|
# WHAT UNIVERSAL TIME is it ? |
|
minute=$(date -u +%M) |
|
heure=$(date -u +%H) |
|
timebar="$heure:$minute" |
|
dayoftheweek=$(date +%w) |
|
dayofthemonth=$(date +%d) |
|
weeknumber=$(date +%V) |
|
|
|
echo $timebar |
|
[[ -f ~/.zen/DEFCON ]] && export DEFCON=$(cat ~/.zen/DEFCON) || export DEFCON=$(cat ~/.zen/astrXbian/DEFCON) # ADAPT $DEFCON scenario |
|
|
|
# ____ _______ __ __ |
|
# / __ \/ ____/ | / / ____ ___ ____ ____/ /__ |
|
# / / / / __/ | | / / / __ `__ \/ __ \/ __ / _ \ |
|
# / /_/ / /___ | |/ / / / / / / / /_/ / /_/ / __/ |
|
# /_____/_____/ |___/ /_/ /_/ /_/\____/\__,_/\___/ |
|
# |
|
# |
|
# ACTIVATE 15-17 MN "git pull" update |
|
if [[ $(($minute % 15)) == 0 ]]; then |
|
########## DESYNCH SWARM NODE REQUESTS ################# |
|
sleep $((1 + RANDOM % 120)) |
|
git pull |
|
fi |
|
|
|
# __ __ _____ ____ |
|
# __/ // /_/ ___/ ______ __________ ___ / __ \ |
|
# /_ _ __/\__ \ | /| / / __ `/ ___/ __ `__ \/ / / / |
|
# /_ _ __/___/ / |/ |/ / /_/ / / / / / / / / /_/ / |
|
# /_//_/ /____/|__/|__/\__,_/_/ /_/ /_/ /_/\____/ |
|
# |
|
################################################################## |
|
# |
|
# REFRESH IPFS SWARM DATA EVERY 20-23 minutes |
|
[[ $(($minute % 20)) == 0 ]] && sleep $((1 + RANDOM % 180)) && $MY_PATH/zen/gchange_INIT.sh && $MY_PATH/zen/gchange_IPFS_swarm.sh & |
|
|
|
# |
|
# _ _ |
|
# __ _| |__ (_) __ _ _ __ |
|
# \ \/ / '_ \| |/ _` | '_ \ |
|
# > <| |_) | | (_| | | | | |
|
# /_/\_\_.__/|_|\__,_|_| |_| ASTROPORT youtube mp3 |
|
# |
|
# ON Rpi/xbian files added in ~/astroport are monitored to activate "new_file_in_astroport.sh" |
|
# Transfert ~/astroport/*/files to IPFS and make Vstream/ASTROPORT indexes in IPNS |
|
if [[ "$USER" == "xbian" ]]; then |
|
# LAUNCH inotifywait |
|
if [[ ! $isinotifywaitRunning ]]; then |
|
mkdir -p /home/$YOU/astroport |
|
/usr/bin/inotifywait -r -e close_write -m /home/$YOU/astroport | while read dir flags file; do $MY_PATH/zen/new_file_in_astroport.sh "$dir" "$file"; done & |
|
fi |
|
|
|
# RESTART inotifywait (may be useless) |
|
if [[ "$timebar" == "03:03" ]]; then |
|
killall inotifywait |
|
fi |
|
fi |
|
## TODO investigate could breaks "ipfs p2p" forwards ? |
|
################################################################## |
|
|
|
# _________ _______ __ _ __ |
|
# / ____< / /_ __/ |/ / ____ ___ ____ ____ (_) /_____ _____ |
|
# / / __ / / / / | / / __ `__ \/ __ \/ __ \/ / __/ __ \/ ___/ |
|
# / /_/ // / / / / | / / / / / / /_/ / / / / / /_/ /_/ / / |
|
# \____//_/ /_/ /_/|_| /_/ /_/ /_/\____/_/ /_/_/\__/\____/_/ |
|
# |
|
################################################################## |
|
# MONITOR INPUT TX (NOT ACTIVATED YET) |
|
# Activate ZenTx => File become a wallet PASSENGER with CONTRACT(s) |
|
# [[ $(($minute % 5)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/g1_MONITOR_zen.sh "5 minutes" |
|
################################################################## |
|
|
|
if [[ "$timebar" == "12:12" || "$timebar" == "00:12" ]]; then |
|
#### DESYNC |
|
sleep $((1 + RANDOM % 5)) |
|
################################################################## |
|
# |
|
# _________ ______ |
|
# ____ ___ ____ /_ __/ | / ____/ |
|
# /_ / / _ \/ __ \ / / / /| |/ / __ |
|
# / /_/ __/ / / / / / / ___ / /_/ / |
|
# /___/\___/_/ /_/ /_/ /_/ |_\____/ |
|
# |
|
# REFRESHing KEY ZenTAG nano DHTs => Zen File ECONOMY door |
|
$MY_PATH/zen/ipns_TAG_refresh.sh |
|
fi |
|
|
|
################################################################## |
|
################################################################## |
|
# MIDNIGHT:01 : CLEANING & UPDATE |
|
################################################################## |
|
################################################################## |
|
if [[ "$timebar" == "00:01" ]]; then |
|
echo ' |
|
# ____ ____ ____ ___ |
|
# / __ \/ __ \ _ / __ < / |
|
# / / / / / / / (_) / / / / / |
|
# / /_/ / /_/ / _ / /_/ / / |
|
# \____/\____/ (_) \____/_/ |
|
# |
|
# MAINTENANCE |
|
' |
|
sleep $((1 + RANDOM % 15)) ### Be careful if random sleep is not activated... |
|
############################## 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. |
|
# GOOD BYE GOOGLE, AMAZON, FACEBOOK, APPLE, MICROSOFT. LIBRE WE ARE. |
|
#################################################################### |
|
# REFRESH & UPGRADE youtube-dl |
|
youtube-dl --rm-cache-dir |
|
youtube-dl -U |
|
|
|
|
|
################################################################## |
|
|
|
if [[ $dayoftheweek == 0 ]]; then |
|
# |
|
# _____ __ __ ___ |
|
# / ___// /_____ _________ _____ ____ / |/ /___ __ __ |
|
# \__ \/ __/ __ \/ ___/ __ `/ __ `/ _ \ / /|_/ / __ `/ |/_/ |
|
# ___/ / /_/ /_/ / / / /_/ / /_/ / __/ / / / / /_/ /> < |
|
# /____/\__/\____/_/ \__,_/\__, /\___/ /_/ /_/\__,_/_/|_| |
|
# /____/ |
|
# 1/2 HDD for IPFS size - dicotomic adaptation 7th EVERY MONTH |
|
availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}') |
|
diskSize="$((availableDiskSize / 2))" |
|
ipfs config Datastore.StorageMax $diskSize |
|
echo "StorageMax = $diskSize" |
|
|
|
# LOG ROTATE |
|
[[ -f /tmp/astroport.log ]] && tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log && echo "" > /tmp/astroport.log |
|
|
|
fi |
|
################################################################## |
|
|
|
|
|
fi
|
|
|