wait a howmany timeout before restarting ipfs

This commit is contained in:
fred 2021-09-22 23:38:04 +02:00
parent 09f5dae89a
commit 52b616fb96
1 changed files with 4 additions and 3 deletions

View File

@ -26,18 +26,19 @@ if [[ ! $IPFSNODEID ]]; then
## wait a howmany timeout before restarting ipfs ## wait a howmany timeout before restarting ipfs
howmany=$((howmany + 1)) && echo $howmany > /tmp/ipfs.timeout howmany=$((howmany + 1)) && echo $howmany > /tmp/ipfs.timeout
[ $howmany -gt 3 ] && [[ -f /etc/sudoers.d/systemctl ]] && echo "IPFS NOT RUNNING $(date)" >> ~/.zen/restart.txt && rm /tmp/ipfs.timeout && sudo systemctl restart ipfs [ $howmany -gt 3 ] && [[ -f /etc/sudoers.d/systemctl ]] && echo "IPFS NOT RUNNING $(date)" >> ~/.zen/restart.txt && rm /tmp/ipfs.timeout && sudo systemctl restart ipfs
[ $howmany -gt 3 ] && [[ "${USER}" == "xbian" ]] && echo "IPFS NOT RUNNING" && sudo service ipfs restart && exit 1
exit 1 exit 1
else else
echo 0 > /tmp/ipfs.timeout echo 0 > /tmp/ipfs.timeout
fi fi
[ $howmany -gt 3 ] && [[ ! $IPFSNODEID && "${USER}" == "xbian" ]] && echo "IPFS NOT RUNNING" && sudo service ipfs restart && exit 1
## CONTROL IPFS IS RUNNING OR RESTART ## CONTROL IPFS IS RUNNING OR RESTART
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
if [[ ! ${YOU} ]]; then if [[ ! ${YOU} ]]; then
# reduice water levels for swarm # control water levels for swarm
ipfs config --json Swarm.ConnMgr.LowWater 50 ipfs config --json Swarm.ConnMgr.LowWater 50
ipfs config --json Swarm.ConnMgr.HighWater 100 ipfs config --json Swarm.ConnMgr.HighWater 100
[[ "${USER}" == "xbian" ]] && sudo service ipfs restart || sudo systemctl restart ipfs [ $howmany -gt 3 ] && [[ "${USER}" == "xbian" ]] && sudo service ipfs restart || sudo systemctl restart ipfs
echo "ERROR! ipfs daemon was not running. RELAUNCHING." echo "ERROR! ipfs daemon was not running. RELAUNCHING."
exit 1 exit 1
fi fi