From b76ebfdfa4a6639caa50ef8bd59dea55343be8fa Mon Sep 17 00:00:00 2001 From: rootzoll Date: Mon, 14 Jan 2019 12:46:19 +0100 Subject: [PATCH] change name of node --- FAQ.md | 6 +- home.admin/config.scripts/lnd.setname.sh | 73 ++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 home.admin/config.scripts/lnd.setname.sh diff --git a/FAQ.md b/FAQ.md index 5ba0d74..510c365 100644 --- a/FAQ.md +++ b/FAQ.md @@ -42,4 +42,8 @@ Recovering the coins that you have in a active channel is a bit more complicated To really have a good backup to rely on such feature needs to be part of the LND software. Almost every other solution would not be perfect. Thats why RaspiBlitz is not trying to provide a backup feature at the moment. -But you can try to backup at your own risk. All your Lightning Node data is within the `/mnt/hdd/lnd` directory. Just run a backup of that data when the lnd service is stopped. \ No newline at end of file +But you can try to backup at your own risk. All your Lightning Node data is within the `/mnt/hdd/lnd` directory. Just run a backup of that data when the lnd service is stopped. + +## How do I change the Name/Alias of my lightning node + +Exit to terminal (X in manin menu). Then enter `sudo nano /mnt/hdd/lnd/lnd.conf` and change the value of the `alias` parameter. Save the your changes with: `CTRL+O` Then exit the editor with: `CTRL+X` And restart your RaspiBlitz with: `sudo shutdown -r now` \ No newline at end of file diff --git a/home.admin/config.scripts/lnd.setname.sh b/home.admin/config.scripts/lnd.setname.sh new file mode 100644 index 0000000..8b3f0ee --- /dev/null +++ b/home.admin/config.scripts/lnd.setname.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "small config script to set a alias of LND (and hostname of raspi)" + echo "lnd.setname.sh [?newName]" + exit 1 +fi + +# 1. parameter [?newName] +newName=$1 + +# run interactive if 'turn on' && no further parameters +if [ ${#newName} -eq 0 ]; then + + dialog --backtitle "Name/Alias" --inputbox "ENTER the new Name for LND node: + +one word, keep basic chars +" 9 52 2>./.tmp + newName=$( cat ./.tmp ) + if [ ${#newName} -eq 0 ]; then + echo "FAIL input cannot be empty" + exit 1 + fi +fi + +# config file +blitzConfig="/mnt/hdd/raspiblitz.conf" + +# lnd conf file +lndConfig="/mnt/hdd/lnd/lnd.conf" + +# check if raspibblitz config file exists +configExists=$(ls ${blitzConfig} | grep -c '.conf') +if [ ${configExists} -eq 0 ]; then + echo "FAIL - missing ${blitzConfig}" + exit 1 +fi + +# make sure entry line for 'hostname' exists +entryExists=$(cat ${blitzConfig} | grep -c 'hostname=') +if [ ${entryExists} -eq 0 ]; then + echo "hostname=" >> ${blitzConfig} +fi + +# check if lnd config file exists +configExists=$(ls ${lndConfig} | grep -c '.conf') +if [ ${configExists} -eq 0 ]; then + echo "FAIL - missing ${lndConfig}" + exit 1 +fi + +# make sure entry line for 'alias' exists +entryExists=$(cat ${lndConfig} | grep -c 'alias=') +if [ ${entryExists} -eq 0 ]; then + echo "alias=" >> ${blitzConfig} +fi + +# stop services +echo "making sure services are not running" +sudo systemctl stop lnd 2>/dev/null + +# lnd.conf: change name +sudo sed -i "s/^alias=.*/alias=${newName}/g" ${lndConfig} + +# raspiblitz.conf: change name +sudo sed -i "s/^hostname=.*/hostname=${newName}/g" ${blitzConfig} + +# OS: change hostname +sudo raspi-config nonint do_hostname ${newName} + +echo "needs reboot to run normal again" +exit 0