raspiblitz/home.admin/config.scripts/cl.check.sh
/rootzoll 75171c09e3
merge prepare v1.9.0rc5 (#3824)
* extend sd card before fatpack (#3783)
* Fatpack sd card expand (#3784)
* extend sd card before fatpack
* fix expansion detection
* Bump lnbits to 0.10.5 and add path to poetry in systemd script (#3787)
* fix: don't reinstall same CLN version + fmt (#3796)
* fix: lnd check for rpcmiddleware (#3804)
* fix: joininbox update, hide jm api error from lcd (#3801)
* fix: hide jm api error from lcd
* joininbox update to v0.7.8
* fix: remove lnbits user when off, improve checks (#3798)
* reduce bitcoind memory usage w  MALLOC_ARENA_MAX=1 (#3780)
* Misc fixed towards v1.9.0 (#3808)
* get web api info
* #3772 increase curl timeout
* #3805 change "Please Login"
* #3807 fix cln jrpc socket access (#3815)
* Btcpay 193 (#3812)
* Update BTCPay v1.9.3
* btcpay verify with web-flow
* lnbits 0.10.6 update (#3814)
* Fatpack: LCD on & cl-plugin.cln-grpc OFF (#3817)
* make sure fatpack is LCD activated
* remove cl-plugin.cln-grpc.sh by default
* #3793 fix socket jrpc
* lndmanage 0.15.0 (#3818)

---------

Co-authored-by: Stephan Oeste <emzy@emzy.de>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
2023-05-11 17:12:28 +02:00

112 lines
3.9 KiB
Bash

#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo
echo "# script to check CL states"
echo "# cl.check.sh basic-setup"
echo "# cl.check.sh prestart [mainnet|testnet|signet]"
echo "# cl.check.sh poststart [mainnet|testnet|signet]"
echo
exit 1
fi
# load variables
source /mnt/hdd/raspiblitz.conf
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2)
######################################################################
# PRESTART
# is executed by systemd cl services everytime BEFORE cl is started
# so it tries to make sure the config is in valid shape
######################################################################
if [ "$1" == "prestart" ]; then
# make sure plugins are loaded https://github.com/rootzoll/raspiblitz/issues/2953
if [ $(grep -c "^plugin-dir=/home/bitcoin/${netprefix}cl-plugins-enabled" < ${CLCONF}) -eq 0 ];then
echo "plugin-dir=/home/bitcoin/${netprefix}cl-plugins-enabled" | tee -a ${CLCONF}
fi
# do not announce 127.0.0.1 https://github.com/rootzoll/raspiblitz/issues/2634
if [ $(grep -c "^announce-addr=127.0.0.1" < ${CLCONF}) -gt 0 ];then
sed -i "/^announce-addr=127.0.0.1/d" ${CLCONF}
fi
if [ $(grep -c "^sparko" < ${CLCONF}) -gt 0 ];then
if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/sparko ]\
|| [ "$(eval echo \$${netprefix}sparko)" != "on" ]; then
echo "# The Sparko plugin is not present but in config"
sed -i "/^sparko/d" ${CLCONF}
rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/sparko
fi
fi
if [ $(grep -c "^clboss" < ${CLCONF}) -gt 0 ];then
if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/clboss ]\
|| [ "$(eval echo \$${netprefix}clboss)" != "on" ]; then
echo "# The clboss plugin is not present but in config"
sed -i "/^clboss/d" ${CLCONF}
rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/clboss
fi
fi
if [ $(grep -c "^http-pass" < ${CLCONF}) -gt 0 ];then
if [ ! -f /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin ]\
|| [ "${clHTTPplugin}" != "on" ]; then
echo "# The clHTTPplugin is not present but in config"
sed -i "/^http-pass/d" ${CLCONF}
rm -rf /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin
fi
fi
if [ $(grep -c "^feeadjuster" < ${CLCONF}) -gt 0 ];then
if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/feeadjuster.py ]\
|| [ "$(eval echo \$${netprefix}feeadjuster)" != "on" ]; then
echo "# The feeadjuster plugin is not present but in config"
sed -i "/^feeadjuster/d" ${CLCONF}
rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/feeadjuster.py
fi
fi
# https://github.com/rootzoll/raspiblitz/issues/3007
# add for test networks as well if needed on mainnet
if [ "${blitzapi}" = "on" ] || \
[ "${LNBitsFunding}" = "${netprefix}cl" ] || \
[ "${BTCPayServer}" = "on" ]; then
if [ $(grep -c "^rpc-file-mode=0660" < ${CLCONF}) -eq 0 ]; then
echo "rpc-file-mode=0660" | tee -a ${CLCONF}
fi
fi
if [ $(grep -c "^grpc-port" < ${CLCONF}) -gt 0 ];then
if [ ! -f /home/bitcoin/${netprefix}cl-plugins-enabled/cln-grpc ]\
|| [ "$(eval echo \$${netprefix}cln-grpc-port)" = "off" ]; then
echo "# The cln-grpc plugin is not present but in config"
sed -i "/^grpc-port/d" ${CLCONF}
rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/cln-grpc
fi
fi
exit 0
fi
######################################################################
# POSTSTART
# is executed by systemd cl services everytime AFTER cl is started
# takes care of things that are just available when CL is running
######################################################################
if [ "$1" == "poststart" ]; then
# log info
info=$(ls -la /mnt/hdd/app-data/.lightning/bitcoin/lightning-rpc)
logger "${info}"
exit 0
fi
echo "# Unkonwn Parameter $1 or missing"
exit 1