From fe291635287878a4da57f95d9637cf67902708fd Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 3 Apr 2019 03:32:58 +0100 Subject: [PATCH] #386 script for setting external IP/Domain --- home.admin/config.scripts/lnd.setaddress.sh | 98 +++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100755 home.admin/config.scripts/lnd.setaddress.sh diff --git a/home.admin/config.scripts/lnd.setaddress.sh b/home.admin/config.scripts/lnd.setaddress.sh new file mode 100755 index 0000000..726bfcc --- /dev/null +++ b/home.admin/config.scripts/lnd.setaddress.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "small config script to set a fixed domain or IP for LND" + echo "internet.dyndomain.sh [domain|ip|off] [?address]" + exit 1 +fi + +# 1. parameter [domain|ip|off] +mode="$1" + +echo "number of args($#)" + +# config file +configFile="/mnt/hdd/raspiblitz.conf" + +# lnd conf file +lndConfig="/mnt/hdd/lnd/lnd.conf" + +# check if config file exists +configExists=$(ls ${configFile} | grep -c '.conf') +if [ ${configExists} -eq 0 ]; then + echo "FAIL - missing ${configFile}" + exit 1 +fi + +# FIXED DOMAIN +if [ "${mode}" = "domain" ]; then + + address=$2 + if [ ${#address} -eq 0 ]; then + echo "missing parameter" + exit(1) + fi + + echo "switching fixed LND Domain ON" + echo "address(${address})" + + # setting value in raspi blitz config + sudo sed -i "s/^lndAddress=.*/lndAddress='${address}'/g" /mnt/hdd/raspiblitz.conf + + echo "changing lnd.conf" + + # lnd.conf: uncomment tlsextradomain (just if it is still uncommented) + sudo sed -i "s/^#tlsextradomain=.*/tlsextradomain=/g" /mnt/hdd/lnd/lnd.conf + + # lnd.conf: domain value + sudo sed -i "s/^tlsextradomain=.*/tlsextradomain=${address}/g" /mnt/hdd/lnd/lnd.conf + + # refresh TLS cert + sudo /home/admin/config.scripts/lnd.newtlscert.sh + + echo "fixedAddress is now ON" +fi + +# FIXED IP +if [ "${mode}" = "ip" ]; then + + address=$2 + if [ ${#address} -eq 0 ]; then + echo "missing parameter" + exit(1) + fi + + echo "switching fixed LND IP ON" + echo "address(${address})" + + # setting value in raspi blitz config + sudo sed -i "s/^lndAddress=.*/lndAddress='${address}'/g" /mnt/hdd/raspiblitz.conf + + echo "fixedAddress is now ON" +fi + +# switch off +if [ "${mode}" = "off" ]; then + echo "switching fixedAddress OFF" + + # stop services + echo "making sure services are not running" + sudo systemctl stop lnd 2>/dev/null + + # setting value in raspi blitz config + sudo sed -i "s/^lndAddress=.*/lndAddress=/g" /mnt/hdd/raspiblitz.conf + + echo "changing lnd.conf" + + # lnd.conf: comment tlsextradomain out + sudo sed -i "s/^tlsextradomain=.*/#tlsextradomain=/g" /mnt/hdd/lnd/lnd.conf + + # refresh TLS cert + sudo /home/admin/config.scripts/lnd.newtlscert.sh + + echo "fixedAddress is now OFF" +fi + +echo "may needs reboot to run normal again" +exit 0 \ No newline at end of file