add cln.setname.sh

make lnd.setname.sh work with parallel wallets
This commit is contained in:
openoms 2021-07-18 15:19:52 +01:00
parent b20a3ee8c3
commit d3a7e40fc5
6 changed files with 89 additions and 21 deletions

View File

@ -108,7 +108,7 @@ case $CHOICE in
# make sure host is named like in the raspiblitz config
echo "Setting the Name/Alias/Hostname .."
sudo /home/admin/config.scripts/lnd.setname.sh ${result}
sudo /home/admin/config.scripts/lnd.setname.sh mainnet ${result}
sudo sed -i "s/^hostname=.*/hostname=${result}/g" /mnt/hdd/raspiblitz.conf
echo "stopping lnd ..."

View File

@ -11,9 +11,9 @@ source <(/home/admin/config.scripts/network.aliases.sh getvars cln $1)
source <(/home/admin/config.scripts/internet.sh status local)
# BASIC MENU INFO
HEIGHT=13
HEIGHT=14
WIDTH=64
CHOICE_HEIGHT=7
CHOICE_HEIGHT=8
BACKTITLE="RaspiBlitz"
TITLE="C-Lightning Options"
MENU=""
@ -25,7 +25,7 @@ OPTIONS+=(CHANNEL "Open a Channel with Peer")
OPTIONS+=(SEND "Pay an Invoice/PaymentRequest")
OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest")
OPTIONS+=(SUMMARY "Information about this node")
#TODO OPTIONS+=(NAME "Change Name/Alias of Node")
OPTIONS+=(NAME "Change Name/Alias of the Node")
ln_getInfo=$($lightningcli_alias getinfo 2>/dev/null)
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
@ -79,15 +79,7 @@ case $CHOICE in
/home/admin/BBcreateInvoice.sh cln $CHAIN
;;
NAME)
sudo /home/admin/config.scripts/lnd.setname.sh
noreboot=$?
if [ "${noreboot}" = "0" ]; then
sudo -u bitcoin ${network}-cli stop
echo "Press ENTER to Reboot."
read key
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 0
fi
sudo /home/admin/config.scripts/cln.setname.sh $CHAIN
;;
SUEZ)
clear

View File

@ -106,7 +106,7 @@ case $CHOICE in
/home/admin/BBcreateInvoice.sh lnd $CHAIN
;;
NAME)
sudo /home/admin/config.scripts/lnd.setname.sh
sudo /home/admin/config.scripts/lnd.setname.sh $CHAIN
noreboot=$?
if [ "${noreboot}" = "0" ]; then
sudo -u bitcoin ${network}-cli stop

View File

@ -181,7 +181,7 @@ if [ "${lightning}" == "lnd" ]; then
sudo cp /home/admin/assets/lnd.${network}.conf /mnt/hdd/lnd/lnd.conf
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
sudo /home/admin/config.scripts/lnd.chain.sh on mainnet
sudo /home/admin/config.scripts/lnd.setname.sh ${hostname}
sudo /home/admin/config.scripts/lnd.setname.sh mainnet ${hostname}
fi
# check if now a config exists

View File

@ -0,0 +1,66 @@
#!/bin/bash
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to set alias of the C-lightning node "
echo "cln.setname.sh [mainnet|testnet|signet] [?newName]"
exit 1
fi
# 1. parameter [?newName]
newName=$2
# use default values from the raspiblitz.conf
source <(/home/admin/config.scripts/network.aliases.sh getvars $1)
# run interactive if 'turn on' && no further parameters
if [ ${#newName} -eq 0 ]; then
sudo rm ./.tmp
dialog --backtitle "Set CLN Name/Alias" --inputbox "ENTER the new Name/Alias for the C-lightning node:
(free to choose, one word up to 32 basic characters)
" 8 56 2>./.tmp
newName=$( cat ./.tmp | tr -dc '[:alnum:]\n\r' )
if [ ${#newName} -eq 0 ]; then
echo "FAIL input cannot be empty"
exit 1
fi
fi
# config file
blitzConfig="/mnt/hdd/raspiblitz.conf"
# cln conf file
clnConfig="/home/bitcoin/.lightning/${netprefix}config"
# check if raspiblitz config file exists
if [ ! -f ${blitzConfig} ]; then
echo "FAIL - missing ${blitzConfig}"
exit 1
fi
# check if cln config file exists
if [ ! -f ${clnConfig} ]; then
echo "FAIL - missing ${clnConfig}"
exit 1
fi
# make sure entry line for 'alias' exists
entryExists=$(cat ${clnConfig} | grep -c "alias=")
if [ ${entryExists} -eq 0 ]; then
echo "alias=" >> ${clnConfig}
fi
# stop services
echo "making sure services are not running"
sudo systemctl stop ${netprefix}lightningd 2>/dev/null
# config: change name
sudo sed -i "s/^alias=.*/alias=${newName}/g" ${clnConfig}
source /home/admin/raspiblitz.info
if [ "${state}" == "ready" ]; then
sudo systemctl start ${netprefix}lightningd
fi
exit 0

View File

@ -3,15 +3,15 @@
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to set a alias of LND (and hostname of raspi)"
echo "lnd.setname.sh [?newName] [?forceHostname]"
echo "lnd.setname.sh [mainnet|testnet|signet] [?newName] [?forceHostname]"
exit 1
fi
# 1. parameter [?newName]
newName=$1
newName=$2
# use default values from the raspiblitz.conf
source <(/home/admin/config.scripts/network.aliases.sh getvars)
source <(/home/admin/config.scripts/network.aliases.sh getvars $2)
# run interactive if 'turn on' && no further parameters
if [ ${#newName} -eq 0 ]; then
@ -33,7 +33,7 @@ blitzConfig="/mnt/hdd/raspiblitz.conf"
# lnd conf file
lndConfig="/mnt/hdd/lnd/${netprefix}lnd.conf"
# check if raspibblitz config file exists
# check if raspiblitz config file exists
configExists=$(ls ${blitzConfig} | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then
echo "FAIL - missing ${blitzConfig}"
@ -62,7 +62,7 @@ fi
# make sure entry line for 'alias' exists
entryExists=$(cat ${lndConfig} | grep -c 'alias=')
if [ ${entryExists} -eq 0 ]; then
echo "alias=" >> ${blitzConfig}
echo "alias=" >> ${lndConfig}
fi
# stop services
@ -77,7 +77,7 @@ sudo sed -i "s/^hostname=.*/hostname=${newName}/g" ${blitzConfig}
# set name in local network just if forced (not anymore by default)
# see https://github.com/rootzoll/raspiblitz/issues/819
if [ "$2" = "alsoNetwork" ]; then
if [ "$3" = "alsoNetwork" ]; then
# OS: change hostname
sudo raspi-config nonint do_hostname ${newName}
sudo sed -i "s/^setnetworkname=.*/setnetworkname=1/g" ${blitzConfig}
@ -85,5 +85,15 @@ else
sudo sed -i "s/^setnetworkname=.*/setnetworkname=0/g" ${blitzConfig}
fi
#TODO - no need for full reboot only unlock LND
#if [ $# -lt 3 ];then
# source /home/admin/raspiblitz.info
# if [ "${state}" == "ready" ]; then
# sudo systemctl start ${netprefix}lnd
# # signal 1 to not reboot
# exit 1
# fi
#fi
echo "needs reboot to run normal again"
exit 0