diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 8131421..f763061 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -32,6 +32,10 @@ if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ]; then echo "*****************************************" echo "If you just started some config/setup, this might be OK." echo + if [ ${startcountBlockchain} -gt 1 ]; then + echo "${startcountBlockchain} RESTARTS DETECTED - ${network}d might be in a error loop" + echo + fi if [ ${#bitcoinErrorFull} -gt 0 ]; then echo "More Error Detail:" echo ${bitcoinErrorFull} @@ -73,6 +77,10 @@ elif [ ${lndActive} -eq 0 ] || [ ${#lndErrorFull} -gt 0 ]; then echo "*********************************" echo "If you just started some config/setup, this might be OK." echo + if [ ${startcountLightning} -gt 1 ]; then + echo "${startcountLightning} RESTARTS DETECTED - ${network}d might be in a error loop" + echo + fi if [ ${#lndErrorFull} -gt 0 ]; then echo "More Error Detail:" echo ${lndErrorFull} diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index 0a47f67..84bade0 100644 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -65,10 +65,10 @@ fi sudo chmod 777 ${infoFile} # resetting start count files -echo "SYSTEMD RESTART LOG: blockchain (bitcoind/litecoind)" > /home/admin/blockchain.systemd.log -echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/lightning.systemd.log -sudo chmod 777 /home/admin/blockchain.systemd.log -sudo chmod 777 /home/admin/lightning.systemd.log +echo "SYSTEMD RESTART LOG: blockchain (bitcoind/litecoind)" > /home/admin/systemd.blockchain.log +echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/systemd.lightning.log +sudo chmod 777 /home/admin/systemd.blockchain.log +sudo chmod 777 /home/admin/systemd.lightning.log # Emergency cleaning logs when over 1GB (to prevent SD card filling up) # see https://github.com/rootzoll/raspiblitz/issues/418#issuecomment-472180944 diff --git a/home.admin/assets/bitcoind.service b/home.admin/assets/bitcoind.service index 6bbb743..495c04f 100644 --- a/home.admin/assets/bitcoind.service +++ b/home.admin/assets/bitcoind.service @@ -13,6 +13,7 @@ User=bitcoin Group=bitcoin Type=forking PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid +ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid KillMode=process Restart=always diff --git a/home.admin/assets/litecoind.service b/home.admin/assets/litecoind.service index 4c92f15..106422b 100644 --- a/home.admin/assets/litecoind.service +++ b/home.admin/assets/litecoind.service @@ -10,6 +10,7 @@ After=bootstrap.service User=bitcoin Group=bitcoin Type=simple +ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf KillMode=process Restart=always diff --git a/home.admin/assets/lnd.service b/home.admin/assets/lnd.service index dfb84d8..1399e5c 100644 --- a/home.admin/assets/lnd.service +++ b/home.admin/assets/lnd.service @@ -10,6 +10,7 @@ After=bitcoind.service [Service] EnvironmentFile=/mnt/hdd/raspiblitz.conf +ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log lightning STARTED ExecStart=/usr/local/bin/lnd --externalip=${publicIP}:${lndPort} PIDFile=/home/bitcoin/.lnd/lnd.pid User=bitcoin diff --git a/home.admin/config.scripts/blitz.statusscan.sh b/home.admin/config.scripts/blitz.statusscan.sh index 730ebfa..b86ecac 100644 --- a/home.admin/config.scripts/blitz.statusscan.sh +++ b/home.admin/config.scripts/blitz.statusscan.sh @@ -28,6 +28,14 @@ echo "tempCelsius='${tempC}'" uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime) echo "uptime=${uptime}" +# count restarts of bitcoind/litecoind +startcountBlockchain=$(cat systemd.blockchain.log | grep -c "STARTED") +echo "startcountBlockchain=${startcountBlockchain}" + +# count restarts of bitcoind/litecoind +startcountLightning=$(cat systemd.lightning.log | grep -c "STARTED") +echo "startcountLightning=${startcountLightning}" + # is bitcoind running bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running) echo "bitcoinActive=${bitcoinRunning}" diff --git a/home.admin/config.scripts/blitz.systemd.sh b/home.admin/config.scripts/blitz.systemd.sh new file mode 100644 index 0000000..de6037d --- /dev/null +++ b/home.admin/config.scripts/blitz.systemd.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# command info +if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "additional systemd services" + echo "blitz.systemd.sh log blockchain STARTED" + echo "blitz.systemd.sh log loghtning STARTED" + exit 1 +fi + +# check parameter +if [ "${1}" != "log" ]; then + echo "# FAIL: unkown parameter" +fi + +# writing log file entry +logFile="/home/admin/systemd.${2}.log" +echo "${3} $(date +%s)" >> ${logFile} +echo "# OK: log '${3}' written to ${logFile}" \ No newline at end of file