make lnd.credentials.sh work for all chains (#3219)

This commit is contained in:
openoms 2022-07-12 13:08:41 +01:00 committed by GitHub
parent a045f18373
commit 261db5104c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 35 additions and 28 deletions

View File

@ -64,12 +64,12 @@ case $CHOICE in
read key
exit 0;;
RESET)
sudo /home/admin/config.scripts/lnd.credentials.sh reset
sudo /home/admin/config.scripts/lnd.credentials.sh sync
sudo /home/admin/config.scripts/lnd.credentials.sh reset "${chain:-main}net"
sudo /home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net"
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 0;;
SYNC)
sudo /home/admin/config.scripts/lnd.credentials.sh sync
sudo /home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net"
echo "Press ENTER to return to main menu."
read key
exit 0;;
@ -176,10 +176,10 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
# have this to signal that selection went wrong
BITCOINRPCPORT=0
fi
echo "# Running on ${chain}net"
echo "# Running on ${chain:-main}net"
echo
allowIPrange=$(grep -c "rpcallowip=$localIPrange" < /mnt/hdd/${network}/${network}.conf)
bindIP=$(grep -c "${chain}.rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf)
bindIP=$(grep -c "${chain:-main}.rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf)
rpcTorService=$(grep -c "HiddenServicePort ${BITCOINRPCPORT} 127.0.0.1:${BITCOINRPCPORT}" < /etc/tor/torrc)
TorRPCaddress=$(sudo cat /mnt/hdd/tor/bitcoin${BITCOINRPCPORT}/hostname)

View File

@ -135,7 +135,7 @@ syncAndCheckLND() # from _provision.setup.sh
done
# now sync macaroons & TLS to other users
sudo /home/admin/config.scripts/lnd.credentials.sh sync
sudo /home/admin/config.scripts/lnd.credentials.sh sync ${chain}net
# make a final lnd check
source <(/home/admin/config.scripts/lnd.check.sh basic-setup "${chain}net")

View File

@ -901,8 +901,8 @@ fi
# make sure users have latest credentials (if lnd is on)
if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then
echo "running LND users credentials update" >> $logFile
/home/admin/config.scripts/lnd.credentials.sh sync >> $logFile
else
/home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net" >> $logFile
else
echo "skipping LND credentials sync" >> $logFile
fi

View File

@ -313,7 +313,7 @@ if [ "${lightning}" == "lnd" ]; then
done
# now sync macaroons & TLS to other users
/home/admin/config.scripts/lnd.credentials.sh sync >> ${logFile}
/home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net" >> ${logFile}
# make a final lnd check
source <(/home/admin/config.scripts/lnd.check.sh basic-setup)

View File

@ -810,8 +810,8 @@ Message: {1}
# if LND REST or LND GRPC service ... add bridge IP to TLS
if blitzServiceName == SERVICE_LND_REST_API or blitzServiceName == SERVICE_LND_GRPC_API:
os.system("sudo /home/admin/config.scripts/lnd.tlscert.sh ip-add {0}".format(subscription['ip']))
os.system("sudo /home/admin/config.scripts/lnd.credentials.sh reset tls")
os.system("sudo /home/admin/config.scripts/lnd.credentials.sh sync")
os.system("sudo /home/admin/config.scripts/lnd.credentials.sh reset mainnet tls")
os.system("sudo /home/admin/config.scripts/lnd.credentials.sh sync mainnet")
# warn user if not delivered as advertised
if subscription['contract_breached']:

View File

@ -60,8 +60,8 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo ln -s /mnt/hdd/app-data/lnd/ /home/circuitbreaker/.lnd
# sync all macaroons and unix groups for access
/home/admin/config.scripts/lnd.credentials.sh sync
# macaroons will be checked after install
/home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net"
# macaroons will be checked after install
# add user to group with admin access to lnd
sudo /usr/sbin/usermod --append --groups lndadmin circuitbreaker

View File

@ -184,7 +184,7 @@ if [ "${mode}" = "on" ] || [ "${mode}" = "1" ]; then
# create symlink
sudo ln -s /mnt/hdd/app-data/lnd/ /home/faraday/.lnd
# sync all macaroons and unix groups for access
/home/admin/config.scripts/lnd.credentials.sh sync
/home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net"
# macaroons will be checked after install
# add user to group with admin access to lnd
sudo /usr/sbin/usermod --append --groups lndadmin faraday

View File

@ -95,7 +95,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/lit/.lnd"
# sync all macaroons and unix groups for access
/home/admin/config.scripts/lnd.credentials.sh sync
/home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net"
# macaroons will be checked after install
# add user to group with admin access to lnd

View File

@ -84,7 +84,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo -u loop /usr/local/go/bin/go install ./... || exit 1
# sync all macaroons and unix groups for access
/home/admin/config.scripts/lnd.credentials.sh sync
/home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net"
# macaroons will be checked after install
# add user to group with admin access to lnd

View File

@ -165,7 +165,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# sudo -u pool /usr/local/go/bin/go install ./... || exit 1
# sync all macaroons and unix groups for access
/home/admin/config.scripts/lnd.credentials.sh sync
/home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net"
# macaroons will be checked after install
# add user to group with admin access to lnd

View File

@ -67,8 +67,8 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# adding zero tier IP to LND TLS cert
# sudo /home/admin/config.scripts/lnd.tlscert.sh ip-add 172.X
# sudo /home/admin/config.scripts/lnd.credentials.sh reset tls
# sudo /home/admin/config.scripts/lnd.credentials.sh sync
# sudo /home/admin/config.scripts/lnd.credentials.sh reset "${chain:-main}net" tls
# sudo /home/admin/config.scripts/lnd.credentials.sh sync "${chain:-main}net"
else
sudo -u admin sudo apt -y purge zerotier-one 1>&2

View File

@ -3,14 +3,21 @@
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "tool to reset or sync credentials (e.g. macaroons)"
echo "lnd.credentials.sh [reset|sync|check] [?tls|macaroons|keepold]"
echo "lnd.credentials.sh [reset|sync|check] <mainnet|testnet|signet> <?tls|macaroons|keepold>"
exit 1
fi
# load data from config
source /mnt/hdd/raspiblitz.conf
# shellcheck disable=SC2154 # gets the ${chain} from the raspiblitz.conf
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd "${chain}net")
if [ $# -gt 1 ]; then
CHAIN=$2
chain=${CHAIN::-3}
else
CHAIN=${chain}net
fi
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${CHAIN})
###########################
# FUNCTIONS
@ -50,25 +57,25 @@ done
if [ "$1" = "reset" ]; then
clear
echo "### lnd.credentials.sh reset"
echo "### lnd.credentials.sh reset ${CHAIN}"
# default reset both
resetTLS=1
resetMacaroons=1
# optional second paramter to just reset one on them
if [ "$2" == "tls" ]; then
if [ "$3" == "tls" ]; then
echo "# just resetting TLS"
resetTLS=1
resetMacaroons=0
fi
if [ "$2" == "macaroons" ]; then
if [ "$3" == "macaroons" ]; then
echo "# just resetting macaroons"
resetTLS=0
resetMacaroons=1
keepOldMacaroons=0
fi
if [ "$2" == "keepold" ]; then
if [ "$3" == "keepold" ]; then
echo "# add the missing default macaroons without de-authenticating the old ones"
resetTLS=0
resetMacaroons=1
@ -112,7 +119,7 @@ if [ "$1" = "reset" ]; then
echo "# OK DONE"
fi
/home/admin/config.scripts/lnd.credentials.sh sync
/home/admin/config.scripts/lnd.credentials.sh sync "${CHAIN}"
###########################
# SYNC
@ -172,7 +179,7 @@ elif [ "$1" = "sync" ]; then
elif [ "$1" = "check" ]; then
check_macaroons "${network}" "${chain}"
if [ $missing -gt 0 ]; then
/home/admin/config.scrips/lnd.credentials.sh reset keepold
/home/admin/config.scrips/lnd.credentials.sh reset "${CHAIN}" keepold
fi
###########################