use function

This commit is contained in:
rootzoll 2021-08-27 15:24:46 +02:00
parent 6a696503b0
commit 8f0bb15518

View file

@ -17,6 +17,22 @@ source /mnt/hdd/raspiblitz.conf
# so it tries to make sure the config is in valid shape
######################################################################
function setting() # FILE LINENUMBER NAME VALUE
{
FILE=$1
LINENUMBER=$2
NAME=$3
VALUE=$4
settingExists=$(sudo cat ${FILE} | grep -c "^${NAME}=")
echo "# ${NAME} exists->(${settingExists})"
if [ "${settingExists}" == "0" ]; then
echo "# adding setting (${NAME})"
sudo sed -i "${LINENUMBER}i${NAME}=" ${FILE}
fi
echo "# updating setting (${NAME}) with value(${VALUE})"
sudo sed -i "s/^${NAME}=.*/${NAME}=${VALUE}/g" ${FILE}
}
# check/repair lnd config before starting
if [ "$1" == "prestart" ]; then
@ -95,6 +111,9 @@ if [ "$1" == "prestart" ]; then
echo "# updating setting (${setting}) with value(${value})"
sudo sed -i "s/^${network}d\.${setting}=.*/${network}d\.${setting}=${value}/g" ${lndConfFile}
# CHECK zmqpubrawblock
setting ${lndConfFile} ${insertLine} "${network}d\.zmqpubrawblock" "tcp\:\/\/127\.0\.0\.1\:${zmqprefix}332"
# remove RPC user & pass from lnd.conf ... since v1.7
# https://github.com/rootzoll/raspiblitz/issues/2160
# echo "- #2160 lnd.conf --> make sure contains no RPC user/pass for bitcoind" >> ${logFile}