raspiblitz/home.admin/config.scripts/lnd.setport.sh

50 lines
1.2 KiB
Bash
Raw Normal View History

2019-02-23 23:44:36 +01:00
#!/bin/bash
# based on: https://github.com/rootzoll/raspiblitz/issues/100#issuecomment-465997126
2019-04-03 01:34:42 +01:00
# based on: https://github.com/rootzoll/raspiblitz/issues/386
2019-02-23 23:44:36 +01:00
if [ $# -eq 0 ]; then
2020-05-28 14:40:48 +02:00
echo "script set the port LND is running on"
2019-02-23 23:44:36 +01:00
echo "lnd.setport.sh [portnumber]"
exit 1
fi
portnumber=$1
2021-08-27 03:59:21 -04:00
# check port number is a integer
2019-02-23 23:50:27 +01:00
if ! [ "$portnumber" -eq "$portnumber" ] 2> /dev/null
then
echo "FAIL - portnumber(${portnumber}) not a number"
exit 1
fi
2019-02-23 23:44:36 +01:00
# check port number is bigger then zero
if [ ${portnumber} -lt 1 ]; then
echo "FAIL - portnumber(${portnumber}) not above 0"
exit 1
fi
# check port number is smaller than max
if [ ${portnumber} -gt 65535 ]; then
echo "FAIL - portnumber(${portnumber}) not below 65535"
exit 1
fi
2019-02-24 01:51:56 +01:00
# check if TOR is on
source /mnt/hdd/raspiblitz.conf
if [ "${runBehindTor}" = "on" ]; then
echo "FAIL - portnumber cannot be changed if TOR is ON (not implemented)"
exit 1
fi
2019-04-03 01:34:42 +01:00
# add to raspiblitz.config (so it can survive update)
/home/admin/config.scripts/blitz.conf.sh set lndPort "${portnumber}"
2019-04-03 01:34:42 +01:00
2019-02-24 01:51:56 +01:00
# enable service again
echo "enable service again"
sudo systemctl restart lnd
2019-02-24 01:51:56 +01:00
# make sure port is open on firewall
sudo ufw allow ${portnumber} comment 'LND Port'
echo "needs reboot to activate new setting -> sudo shutdown -r now"