check sbotc is working every 5 mn instead of 1

This commit is contained in:
qo-op 2020-06-13 13:30:51 +02:00
parent 1dbee81e86
commit 09ca7a8b77
1 changed files with 18 additions and 25 deletions

View File

@ -13,29 +13,13 @@ ME="${0##*/}"
[[ ! $(echo $PATH | grep "~/.local/bin") ]] && export PATH="$PATH:~/.local/bin"
[[ ! $(echo $PATH | grep "/usr/games") ]] && export PATH="$PATH:/usr/games"
####
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"
#### INIT STATION PARAMETERS
[[ -f $MY_PATH/../secret.astroport.key ]] && source $MY_PATH/../secret.astroport.key
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
source /home/$YOU/.profile
export IPFSNODEID=$(ipfs id -f='<id>\n') || er+=" ipfs id problem"
export WHOAMI=$($MY_PATH/zen/tools/timeout.sh -t 8 sbotc whoami | jq -r .id)
[[ $IPFSNODEID ]] && export IPFSNODEID=$IPFSNODEID || export IPFSNODEID=$(ipfs id -f='<id>\n')
[[ $WHOAMI ]] && export WHOAMI=$WHOAMI || export WHOAMI=$($MY_PATH/zen/tools/timeout.sh -t 8 sbotc whoami | jq -r .id)
if [[ "$WHOAMI" == "" ]]; then
### oasis ssb-server not responding!!!
echo "sbotc <-> ssb-server communication broken... restarting ssb-server !"
ssb_process=$(ps auxf --sort=+utime | grep -w 'ssb-server' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
kill -9 $ssb_process
sleep 5
ssb_newprocess=$(ps auxf --sort=+utime | grep -w 'ssb-server' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
if [[ ! $ssb_newprocess ]]; then
while true; do ssb-server start; sleep 3; done &
fi
# kill -9 $(ps auxf --sort=+utime | grep -w 'oasis' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
# oasis --allow-host oasis.astroport.com --host oasis.astroport.com &
fi
########################################################################
# HELP DEVLT: Search "TODO" in code
# Write what you thing about the situation
@ -115,12 +99,21 @@ fi
#
# ACTIVATE 5 MN "git pull" update
if [[ $(($minute % 5)) == 0 ]]; then
sleep $((1 + RANDOM % 12))
### Remove files being in .gitignore
# git checkout -- www/LOVELand/jukebox/prefs/collection.sq3
# git checkout -- www/LOVELand/jukebox/prefs/prefs.var
#######################################
sleep $((1 + RANDOM % 12))
git pull
### CHECK IF sbotc is working
if [[ "$($MY_PATH/zen/tools/timeout.sh -t 8 sbotc whoami | jq -r .id)" == "" ]]; then
### ssb-server not responding!!!
echo "sbotc <-> ssb-server communication broken... restarting ssb-server !"
ssb_process=$(ps auxf --sort=+utime | grep -w 'ssb-server' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
kill -9 $ssb_process; sleep 5
ssb_newprocess=$(ps auxf --sort=+utime | grep -w 'ssb-server' | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
if [[ ! $ssb_newprocess ]]; then
while true; do ssb-server start; sleep 3; done &
fi
fi
fi
# __________ ____ __ ________ ___________