apply bitcoin and lncli aliases in all scripts

This commit is contained in:
openoms 2021-06-23 08:30:52 +01:00
parent 3a054d6f9f
commit 8bc31b6698
No known key found for this signature in database
GPG Key ID: 5BFB77609B081B65
8 changed files with 30 additions and 16 deletions

View File

@ -158,8 +158,11 @@ if [ "${chain}" != "${choice}" ]; then
echo "B) Answer 'n' because you don't have a 'cipher seed mnemonic' (24 words) yet"
echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)"
echo "****************************************************************************"
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>error.out
error=`sudo cat error.out`
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${choice}net)
shopt -s expand_aliases
alias lncli_alias="$lncli_alias"
lncli_alias create 2>error.out
error=$(sudo cat error.out)
if [ ${#error} -eq 0 ]; then
sleep 2
# WIN

View File

@ -50,6 +50,11 @@ fi
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
if [ ${lndRunning} -eq 1 ]; then
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd)
shopt -s expand_aliases
alias bitcoincli_alias="$bitcoincli_alias"
alias lncli_alias="$lncli_alias"
echo "LND is running ..."
sleep 1
@ -60,7 +65,7 @@ if [ ${lndRunning} -eq 1 ]; then
if [ ${walletExists} -eq 1 ];then
echo "lnd wallet exists ... checking if locked"
sleep 2
walletLocked=$(sudo -u bitcoin /usr/local/bin/lncli getinfo 2>&1 | grep -c unlock)
walletLocked=$($lncli_alias getinfo 2>&1 | grep -c unlock)
fi
if [ ${walletLocked} -gt 0 ]; then
# LND wallet is locked
@ -70,7 +75,7 @@ if [ ${lndRunning} -eq 1 ]; then
fi
# check if blockchain still syncing (during sync sometimes CLI returns with error at this point)
chainInfo=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep 'initialblockdownload')
chainInfo=$($bitcoincli_alias getblockchaininfo 2>/dev/null | grep 'initialblockdownload')
chainSyncing=1
if [ ${#chainInfo} -gt 0 ];then
echo "check chaininfo"
@ -86,7 +91,7 @@ if [ ${lndRunning} -eq 1 ]; then
fi
# check if lnd is scanning blockchain
lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | grep "synced_to_chain")
lndInfo=$($lncli_alias --chain=${network} getinfo 2>/dev/null | grep "synced_to_chain")
lndSyncing=1
if [ ${#lndInfo} -gt 0 ];then
lndSyncing=$(echo "${chainInfo}" | grep "false" -c)

View File

@ -22,11 +22,11 @@ if [ ${#chain} -eq 0 ]; then
fi
# CHECK #########
source <(/home/admin/config.scripts/network.aliases.sh getvars)
echo "*** Check ${network} Running ***"
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
bitcoinRunning=$(systemctl status ${netprefix}${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then
bitcoinRunning=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | grep -c verificationprogress)
bitcoinRunning=$($bitcoincli_alias getblockchaininfo | grep -c verificationprogress)
fi
if [ ${bitcoinRunning} -eq 0 ]; then
whiptail --title "70initLND - WARNING" --yes-button "Retry" --no-button "EXIT+Logs" --yesno "Service ${network}d is not running." 8 50
@ -46,7 +46,7 @@ loopCount=0
while [ ${chainIsReady} -eq 0 ]
do
loopCount=$(($loopCount +1))
result=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>error.out)
result=$($bitcoincli_alias getblockchaininfo 2>error.out)
error=$(cat error.out)
rm error.out
if [ ${#error} -gt 0 ]; then

View File

@ -8,6 +8,8 @@ source /mnt/hdd/raspiblitz.conf
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd $1)
# BASIC MENU INFO
HEIGHT=13
WIDTH=64
@ -33,7 +35,7 @@ fi
OPTIONS+=(NAME "Change Name/Alias of Node")
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
openChannels=$($lncli_alias listchannels 2>/dev/null | jq '.[] | length')
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels")
HEIGHT=$((HEIGHT+1))

View File

@ -18,9 +18,12 @@ echo "**************************************************************************
echo "HELP: Enter your PASSWORD C"
echo "You may wait some seconds until you get asked for password."
echo "****************************************************************************"
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd)
shopt -s expand_aliases
alias lncli_alias="$lncli_alias"
while :
do
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} unlock
lncli_alias --chain=${network} unlock
sleep 4
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
if [ ${locked} -eq 0 ]; then

View File

@ -53,7 +53,7 @@ fi
# info output
clear
echo "******************************"
echo "Connect to A Lightning Node"
echo "Connect to a Lightning Node"
echo "******************************"
echo
echo "COMMAND LINE: "

View File

@ -400,7 +400,8 @@ do
if [ "${autoUnlock}" = "on" ]; then
# check if lnd is locked
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd)
locked=$($lncli_alias getinfo 2>&1 | grep -c unlock)
if [ ${locked} -gt 0 ]; then
echo "STARTING AUTO-UNLOCK ..."
@ -441,7 +442,8 @@ do
# check if flag exists (got created on 50syncHDD.sh)
flagExists=$(ls /mnt/hdd/${network}/blocks/selfsync.flag 2>/dev/null | grep -c "selfsync.flag")
if [ ${flagExists} -eq 1 ]; then
finishedIBD=$(sudo -u bitcoin ${network}-cli getblockchaininfo | grep "initialblockdownload" | grep -c "false")
source <(/home/admin/config.scripts/network.aliases.sh getvars)
finishedIBD=$($bitcoincli_alias getblockchaininfo | grep "initialblockdownload" | grep -c "false")
if [ ${finishedIBD} -eq 1 ]; then
echo "CHECK FOR END OF IBD --> reduce RAM, check TOR and restart ${network}d"

View File

@ -1,7 +1,7 @@
#!/bin/bash
# Usage:
# source <(/home/admin/config.scripts/network.aliases.sh <lnd|cln> <mainnet|testnet|signet>
# source <(/home/admin/config.scripts/network.aliases.sh getvars <lnd|cln> <mainnet|testnet|signet>)
# shopt -s expand_aliases
# alias bitcoincli_alias="$bitcoincli_alias"
# alias lncli_alias="$lncli_alias"
@ -55,7 +55,6 @@ if [ $1 = getvars ];then
echo "portprefix=''"
fi
#TODO ALL
# instead of all
# sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net
echo "lncli_alias=\"sudo -u bitcoin /usr/local/bin/lncli -n=${chain}net --rpcserver localhost:1${L2rpcportmod}009\""