Skip to content

Commit

Permalink
first version if lnd.setport.sh raspiblitz#100
Browse files Browse the repository at this point in the history
  • Loading branch information
rootzoll committed Feb 24, 2019
1 parent c46a18f commit e37a533
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions home.admin/config.scripts/lnd.setport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,49 @@ if [ ${portnumber} -gt 65535 ]; then
exit 1
fi

# 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

# check lnd.conf exits
lndConfExists=$(sudo ls /mnt/hdd/lnd/lnd.conf | grep -c 'lnd.conf')
if [ ${lndConfExists} -eq 0 ]; then
echo "FAIL - /mnt/hdd/lnd/lnd.conf not found"
exit 1
fi

echo "DEBUG EXIT"
exit 0

# check if "listen=" exists in lnd config
valueExists=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'nat=')
if [ ${valueExists} -eq 0 ]; then
echo "Adding autonat config defaults to /mnt/hdd/lnd/lnd.conf"
sudo sed -i '$ a listen=0.0.0.0:9735' /mnt/hdd/lnd/lnd.conf
valueExists=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'listen=')
if [ ${valueExists} -lt 3 ]; then
echo "Adding listen config defaults to /mnt/hdd/lnd/lnd.conf"
sudo sed -i "9i listen=0.0.0.0:9735" /mnt/hdd/lnd/lnd.conf
fi

# stop services
echo "making sure services are not running"
echo "making sure LND is not running"
sudo systemctl stop lnd 2>/dev/null

echo "needs reboot to activate new setting"
# disable services
echo "making sure LND is disabled"
sudo systemctl disable lnd

# change port in lnd config
echo "change port in lnd config"
sudo sed -i "s/^listen=.*/listen=0.0.0.0:${portnumber}/g" /mnt/hdd/lnd/lnd.conf

# editing service file
echo "editing /etc/systemd/system/lnd.service"
sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}:${portnumber}/g" /etc/systemd/system/lnd.service

# enable service again
echo "enable service again"
sudo systemctl enable lnd

# make sure port is open on firewall
sudo ufw allow ${portnumber} comment 'LND Port'
sudo ufw --force enable

echo "needs reboot to activate new setting -> sudo shutdown -r now"

0 comments on commit e37a533

Please sign in to comment.