fix: lnd check for rpcmiddleware (#3804)

This commit is contained in:
openoms 2023-05-08 19:35:18 +01:00 committed by GitHub
parent 4e1f2a4ae9
commit 029525ab4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 57 deletions

View file

@ -5,10 +5,10 @@ LITVERSION="0.9.2-alpha"
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch the Lightning Terminal Service on or off"
echo "installs the version $LITVERSION"
echo "bonus.lit.sh [on|off|menu]"
exit 1
echo "config script to switch the Lightning Terminal Service on or off"
echo "installs the version $LITVERSION"
echo "bonus.lit.sh [on|off|menu]"
exit 1
fi
# check who signed the release in https://github.com/lightninglabs/lightning-terminal/releases
@ -78,16 +78,16 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# switching off single installs of pool, loop or faraday if installed
if [ "${loop}" = "on" ]; then
echo "# Replacing single install of: LOOP"
/home/admin/config.scripts/bonus.loop.sh off
echo "# Replacing single install of: LOOP"
/home/admin/config.scripts/bonus.loop.sh off
fi
if [ "${pool}" = "on" ]; then
echo "# Replacing single install of: POOL"
/home/admin/config.scripts/bonus.pool.sh off
echo "# Replacing single install of: POOL"
/home/admin/config.scripts/bonus.pool.sh off
fi
if [ "${faraday}" = "on" ]; then
echo "# Replacing single install of: FARADAY"
/home/admin/config.scripts/bonus.faraday.sh off
echo "# Replacing single install of: FARADAY"
/home/admin/config.scripts/bonus.faraday.sh off
fi
isInstalled=$(sudo ls /etc/systemd/system/litd.service 2>/dev/null | grep -c 'litd.service')
@ -96,7 +96,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# create dedicated user
sudo adduser --disabled-password --gecos "" lit
# make sure symlink to central app-data directory exists
sudo rm -rf /home/lit/.lnd # not a symlink.. delete it silently
sudo rm -rf /home/lit/.lnd # not a symlink.. delete it silently
# create symlink
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/lit/.lnd"
@ -160,21 +160,21 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
uname -m
exit 1
else
echo "OK running on $(uname -m) architecture."
echo "OK running on $(uname -m) architecture."
fi
downloadDir="/home/admin/download/lit" # edit your download directory
downloadDir="/home/admin/download/lit" # edit your download directory
rm -rf "${downloadDir}"
mkdir -p "${downloadDir}"
cd "${downloadDir}" || exit 1
# extract the SHA256 hash from the manifest file for the corresponding platform
wget -N https://github.com/lightninglabs/lightning-terminal/releases/download/v${LITVERSION}/manifest-v${LITVERSION}.txt
if [ ${isARM} -eq 1 ] ; then
if [ ${isARM} -eq 1 ]; then
OSversion="armv7"
elif [ ${isAARCH64} -eq 1 ] ; then
elif [ ${isAARCH64} -eq 1 ]; then
OSversion="arm64"
elif [ ${isX86_64} -eq 1 ] ; then
elif [ ${isX86_64} -eq 1 ]; then
OSversion="amd64"
fi
SHA256=$(grep -i "linux-$OSversion" manifest-v$LITVERSION.txt | cut -d " " -f1)
@ -198,8 +198,8 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# check gpg finger print"
gpg --show-keys --keyid-format LONG ./pgp_keys.asc
fingerprint=$(gpg --show-keys --keyid-format LONG "./pgp_keys.asc" 2>/dev/null \
| grep "${PGPcheck}" -c)
fingerprint=$(gpg --show-keys --keyid-format LONG "./pgp_keys.asc" 2>/dev/null |
grep "${PGPcheck}" -c)
if [ ${fingerprint} -lt 1 ]; then
echo ""
echo "# BUILD WARNING --> LiT PGP author not as expected"
@ -209,7 +209,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
fi
gpg --import ./pgp_keys.asc
sleep 3
verifyResult=$(LANG=en_US.utf8; gpg --verify manifest-v${LITVERSION}.sig manifest-v${LITVERSION}.txt 2>&1)
verifyResult=$(
LANG=en_US.utf8
gpg --verify manifest-v${LITVERSION}.sig manifest-v${LITVERSION}.txt 2>&1
)
goodSignature=$(echo ${verifyResult} | grep 'Good signature' -c)
echo "goodSignature(${goodSignature})"
correctKey=$(echo ${verifyResult} | tr -d " \t\n\r" | grep "${GPGcheck}" -c)
@ -235,17 +238,14 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
###########
# config #
###########
# check if lnd.conf has rpcmiddleware.enable entry under section Application Options
entryExists=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c "rpcmiddleware.enable=")
if [ "${entryExists}" == "0" ]; then
echo "# add rpcmiddleware.enable=true to lnd.conf"
sudo sed -i "/^\[Application Options\]$/arpcmiddleware.enable=true" /mnt/hdd/lnd/lnd.conf
# check if lnd.conf has rpcmiddleware.enable entry under [rpcmiddleware]
if sudo grep rpcmiddleware /mnt/hdd/lnd/lnd.conf; then
sudo sed -i "s/^rpcmiddleware.enable=.*/rpcmiddleware.enable=true/g" /mnt/hdd/lnd/lnd.conf
else
sudo bash -c "echo '[rpcmiddleware]' >> /mnt/hdd/lnd/lnd.conf"
sudo bash -c "echo 'rpcmiddleware.enable=true' >> /mnt/hdd/lnd/lnd.conf"
fi
# make sure lnd.conf has rpcmiddleware.enable=true
sudo sed -i "s/^rpcmiddleware.enable=.*/rpcmiddleware.enable=true/g" /mnt/hdd/lnd/lnd.conf
if [ "${runBehindTor}" = "on" ]; then
echo "# Connect to the Pool, Loop and Terminal server through Tor"
LOOPPROXY="loop.server.proxy=127.0.0.1:9050"
@ -408,4 +408,3 @@ fi
echo "FAIL - Unknown Parameter $1"
echo "may need reboot to run normal again"
exit 1

View file

@ -22,8 +22,7 @@ echo "# lndConfFile(${lndConfFile})"
# so it tries to make sure the config is in valid shape
######################################################################
function setting() # FILE LINENUMBER NAME VALUE
{
function setting() { # FILE LINENUMBER NAME VALUE
FILE=$1
LINENUMBER=$2
NAME=$3
@ -118,7 +117,6 @@ if [ "$1" == "prestart" ]; then
echo "# ${network}.node insert/update"
setting ${lndConfFile} ${insertLine} "${network}\.node" "${network}d"
##### BITCOIND OPTIONS SECTION #####
# [bitcoind]
@ -164,7 +162,7 @@ if [ "$1" == "prestart" ]; then
RPCPSW=$(cat /mnt/hdd/${network}/${network}.conf | grep "^${network}d.rpcpassword=" | cut -d "=" -f2 | tail -n 1)
fi
if [ "${RPCPSW}" == "" ]; then
1>&2 echo "FAIL: 'rpcpassword' not found in /mnt/hdd/${network}/${network}.conf"
echo 1>&2 "FAIL: 'rpcpassword' not found in /mnt/hdd/${network}/${network}.conf"
exit 11
fi
setting ${lndConfFile} ${insertLine} "${network}d\.rpcpass" "${RPCPSW}"
@ -175,7 +173,7 @@ if [ "$1" == "prestart" ]; then
RPCUSER=$(cat /mnt/hdd/${network}/${network}.conf | grep "^${network}d.rpcuser=" | cut -d "=" -f2 | tail -n 1)
fi
if [ "${RPCUSER}" == "" ]; then
1>&2 echo "FAIL: 'rpcuser' not found in /mnt/hdd/${network}/${network}.conf"
echo 1>&2 "FAIL: 'rpcuser' not found in /mnt/hdd/${network}/${network}.conf"
exit 12
fi
setting ${lndConfFile} ${insertLine} "${network}d\.rpcuser" "${RPCUSER}"
@ -258,7 +256,7 @@ if [ "$1" == "prestart" ]; then
# limit workers to the number of cores
setting ${lndConfFile} ${insertLine} "workers.write" "${cores}"
setting ${lndConfFile} ${insertLine} "workers.sig" "${cores}"
fi
fi
##### TOR SECTION #####
@ -296,7 +294,7 @@ fi
# take care of incompatible settings https://github.com/rootzoll/raspiblitz/issues/2787#issuecomment-991245694
if [ $(cat ${lndConfFile} | grep -c "^tor.skip-proxy-for-clearnet-targets=true") -gt 0 ] ||
[ $(cat ${lndConfFile} | grep -c "^tor.skip-proxy-for-clearnet-targets=1") -gt 0 ]; then
[ $(cat ${lndConfFile} | grep -c "^tor.skip-proxy-for-clearnet-targets=1") -gt 0 ]; then
setting ${lndConfFile} ${insertLine} "tor.streamisolation" "false"
fi
@ -308,7 +306,7 @@ fi
##### RPCMIDDLEWARE SECTION #####
# [rpcmiddleware]
sectionName="[Rr]pcmiddleware"
sectionName="rpcmiddleware"
echo "# [${sectionName}] config ..."
# make sure lnd config has a [rpcmiddleware] section
@ -337,7 +335,6 @@ fi
# SET/UPDATE rpcmiddleware.enable
setting ${lndConfFile} ${insertLine} "rpcmiddleware.enable" "true"
echo "# OK PRESTART DONE"
######################################################################
@ -411,25 +408,25 @@ elif [ "$1" == "basic-setup" ]; then
echo "err='$(netprefix)lnd.conf: blockchain network in $(netprefix)lnd.conf (${lndNetwork}) is different from raspiblitz.conf (${network})'"
fi
# # get chain from config (TESTNET / MAINNET)
# lndChain=""
# source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.mainnet" | sed 's/^[a-z]*\.//g')
# source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.testnet" | sed 's/^[a-z]*\.//g')
# if [ "${mainnet}" == "1" ] && [ "${testnet}" == "1" ]; then
# echo "err='lnd.conf: mainnet and testnet are set active at the same time'"
# elif [ "${mainnet}" == "1" ]; then
# lndChain="main"
# elif [ "${testnet}" == "1" ]; then
# lndChain="test"
# else
# echo "err='lnd.conf: neither testnet or mainnet is set active (raspiblitz needs one of them active in lnd.conf)'"
# fi
# echo "chain='${lndChain}'"
#
# # check if chain is same the raspiblitz config
# if [ "${chain}" != "${lndChain}" ]; then
# echo "err='lnd.conf: testnet/mainnet in lnd.conf (${lndChain}) is different from raspiblitz.conf (${chain})'"
# fi
# # get chain from config (TESTNET / MAINNET)
# lndChain=""
# source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.mainnet" | sed 's/^[a-z]*\.//g')
# source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.testnet" | sed 's/^[a-z]*\.//g')
# if [ "${mainnet}" == "1" ] && [ "${testnet}" == "1" ]; then
# echo "err='lnd.conf: mainnet and testnet are set active at the same time'"
# elif [ "${mainnet}" == "1" ]; then
# lndChain="main"
# elif [ "${testnet}" == "1" ]; then
# lndChain="test"
# else
# echo "err='lnd.conf: neither testnet or mainnet is set active (raspiblitz needs one of them active in lnd.conf)'"
# fi
# echo "chain='${lndChain}'"
#
# # check if chain is same the raspiblitz config
# if [ "${chain}" != "${lndChain}" ]; then
# echo "err='lnd.conf: testnet/mainnet in lnd.conf (${lndChain}) is different from raspiblitz.conf (${chain})'"
# fi
# check for admin macaroon exist (on HDD)
adminMacaroonExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c 'admin.macaroon')