From 3b90f34ee1be04634f3a0ba0219c455863fec6a3 Mon Sep 17 00:00:00 2001 From: /geco Date: Sun, 23 Dec 2018 21:31:47 +0100 Subject: [PATCH] fix tls rest config --- home.admin/assets/lnd.bitcoin.conf | 1 + home.admin/assets/lnd.litecoin.conf | 1 + home.admin/config.scripts/lnd.autounlock.sh | 39 ++++++++++----------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/home.admin/assets/lnd.bitcoin.conf b/home.admin/assets/lnd.bitcoin.conf index 645ed48..05537ec 100755 --- a/home.admin/assets/lnd.bitcoin.conf +++ b/home.admin/assets/lnd.bitcoin.conf @@ -13,6 +13,7 @@ rpclisten=0.0.0.0:10009 restlisten=0.0.0.0:8080 # Domain, could use https://freedns.afraid.org #tlsextradomain=lightning.yourhost.com +tlsextraip=0.0.0.0 [Bitcoin] bitcoin.active=1 diff --git a/home.admin/assets/lnd.litecoin.conf b/home.admin/assets/lnd.litecoin.conf index a44469d..bf9bdc1 100755 --- a/home.admin/assets/lnd.litecoin.conf +++ b/home.admin/assets/lnd.litecoin.conf @@ -14,6 +14,7 @@ restlisten=0.0.0.0:8080 # Domain, could use https://freedns.afraid.org #tlsextradomain=lightning.yourhost.com +tlsextraip=0.0.0.0 [Litecoin] litecoin.active=1 diff --git a/home.admin/config.scripts/lnd.autounlock.sh b/home.admin/config.scripts/lnd.autounlock.sh index 0cc8096..5f34651 100755 --- a/home.admin/config.scripts/lnd.autounlock.sh +++ b/home.admin/config.scripts/lnd.autounlock.sh @@ -55,27 +55,26 @@ fi # switch on if [ "$1" = "1" ] || [ "$1" = "on" ]; then - # make sure REST config of LND is correct - restActive=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'restlisten=0.0.0.0:8080') - if [ ${restActive} -eq 0 ]; then - restActive=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'restlisten=') - if [ ${restActive} -eq 1 ]; then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "FAIL: /mnt/hdd/lnd/lnd.conf includes REST config NOT 'restlisten=0.0.0.0:8080'" - echo "CANNOT ACTIVATE REST like needed for auto-unlock" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - sleep 5 - exit 1 - else - # add REST config to lnd.conf (for old configs) - sudo sh -c "echo \"restlisten=0.0.0.0:8080\" >> /mnt/hdd/lnd/lnd.conf" - echo "LND REST config added -> restlisten=0.0.0.0:8080'" - # refresh TLS cert - sudo /home/admin/config.scripts/lnd.newtlscert.sh - fi - else - echo "LND REST config OK -> restlisten=0.0.0.0:8080'" + # make sure config values are uncommented + sudo sed -i "s/^#restlisten=.*/restlisten=/g" /mnt/hdd/lnd/lnd.conf + sudo sed -i "s/^#tlsextraip=.*/tlsextraip=/g" /mnt/hdd/lnd/lnd.conf + + # make sure config values exits + exists=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'restlisten=') + if [ ${exists} -eq 0 ]; then + sudo sh -c "echo \"restlisten=\" >> /mnt/hdd/lnd/lnd.conf" fi + exists=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'tlsextraip') + if [ ${exists} -eq 0 ]; then + sudo sh -c "echo \"tlsextraip=\" >> /mnt/hdd/lnd/lnd.conf" + fi + + # set needed config values + sudo sed -i "s/^restlisten=.*/restlisten=0.0.0.0:8080/g" /mnt/hdd/lnd/lnd.conf + sudo sed -i "s/^tlsextraip=.*/tlsextraip=0.0.0.0/g" /mnt/hdd/lnd/lnd.conf + + # refresh TLS cert + sudo /home/admin/config.scripts/lnd.newtlscert.sh echo "switching the Auto-Unlock ON"