From cb7cd4f902838787403818000c359989b0ece7d2 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Fri, 22 Feb 2019 22:46:13 +0100 Subject: [PATCH 1/5] optional continue in PGP autocheck #342 --- build_sdcard.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build_sdcard.sh b/build_sdcard.sh index ede9eeb82..bc7ac8ffe 100644 --- a/build_sdcard.sh +++ b/build_sdcard.sh @@ -246,8 +246,12 @@ fi fingerprint=$(gpg ./laanwj-releases.asc 2>/dev/null | grep "${laanwjPGP}" -c) if [ ${fingerprint} -lt 1 ]; then echo "" - echo "!!! BUILD FAILED --> Bitcoin download PGP author not OK" - exit 1 + echo "!!! BUILD WARNING --> Bitcoin PGP author not as expected" + echo "Should be laanwjPGP: ${laanwjPGP}" + echo "This is the output of that check (gpg ./laanwj-releases.asc):" + gpg ./laanwj-releases.asc + echo "PRESS ENTER to TAKE THE RISK if you think all is OK" + read key fi gpg --import ./laanwj-releases.asc sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/SHA256SUMS.asc From becad8e301a699cc0405ecd5f68ab0d0eed2ccf4 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Fri, 22 Feb 2019 23:22:03 +0100 Subject: [PATCH 2/5] optional continue on PGP check --- build_sdcard.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build_sdcard.sh b/build_sdcard.sh index bc7ac8ffe..698388771 100644 --- a/build_sdcard.sh +++ b/build_sdcard.sh @@ -243,13 +243,12 @@ then echo "!!! FAIL !!! Download laanwj-releases.asc not success." exit 1 fi +gpg ./laanwj-releases.asc fingerprint=$(gpg ./laanwj-releases.asc 2>/dev/null | grep "${laanwjPGP}" -c) if [ ${fingerprint} -lt 1 ]; then echo "" echo "!!! BUILD WARNING --> Bitcoin PGP author not as expected" - echo "Should be laanwjPGP: ${laanwjPGP}" - echo "This is the output of that check (gpg ./laanwj-releases.asc):" - gpg ./laanwj-releases.asc + echo "Should contain laanwjPGP: ${laanwjPGP}" echo "PRESS ENTER to TAKE THE RISK if you think all is OK" read key fi @@ -336,11 +335,14 @@ if [ "${binaryChecksum}" != "${lndSHA256}" ]; then fi # check gpg finger print +gpg ./pgp_keys.asc fingerprint=$(gpg ./pgp_keys.asc 2>/dev/null | grep "${olaoluwaPGP}" -c) if [ ${fingerprint} -lt 1 ]; then echo "" - echo "!!! BUILD FAILED --> LND download author PGP not OK" - exit 1 + echo "!!! BUILD WARNING --> Bitcoin PGP author not as expected" + echo "Should contain olaoluwaPGP: ${olaoluwaPGP}" + echo "PRESS ENTER to TAKE THE RISK if you think all is OK" + read key fi gpg --import ./pgp_keys.asc sleep 3 From 5d8d5e9a237f43b6093a7f54db3f93d2ef16c3fb Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sat, 23 Feb 2019 23:44:36 +0100 Subject: [PATCH 3/5] #100 beginning of set lnd port script --- home.admin/config.scripts/lnd.setport.sh | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 home.admin/config.scripts/lnd.setport.sh diff --git a/home.admin/config.scripts/lnd.setport.sh b/home.admin/config.scripts/lnd.setport.sh new file mode 100644 index 000000000..bb2891e29 --- /dev/null +++ b/home.admin/config.scripts/lnd.setport.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# based on: https://github.com/rootzoll/raspiblitz/issues/100#issuecomment-465997126 + +if [ $# -eq 0 ]; then + echo "small config script set the port LND is running on" + echo "lnd.setport.sh [portnumber]" + exit 1 +fi + +portnumber=$1 + +# 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 + +# 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 +fi + +# stop services +echo "making sure services are not running" +sudo systemctl stop lnd 2>/dev/null + +echo "needs reboot to activate new setting" \ No newline at end of file From c46a18f89f0b9af03b285b4ce39bb50bd199e42c Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sat, 23 Feb 2019 23:50:27 +0100 Subject: [PATCH 4/5] add integer check --- home.admin/config.scripts/lnd.setport.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/home.admin/config.scripts/lnd.setport.sh b/home.admin/config.scripts/lnd.setport.sh index bb2891e29..b7fb24689 100644 --- a/home.admin/config.scripts/lnd.setport.sh +++ b/home.admin/config.scripts/lnd.setport.sh @@ -10,6 +10,13 @@ fi portnumber=$1 +# check port numer is a integer +if ! [ "$portnumber" -eq "$portnumber" ] 2> /dev/null +then + echo "FAIL - portnumber(${portnumber}) not a number" + exit 1 +fi + # check port number is bigger then zero if [ ${portnumber} -lt 1 ]; then echo "FAIL - portnumber(${portnumber}) not above 0" From e37a5336f92728d3a07db473065e91a7e4f59b1d Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 24 Feb 2019 01:51:56 +0100 Subject: [PATCH 5/5] first version if lnd.setport.sh #100 --- home.admin/config.scripts/lnd.setport.sh | 42 +++++++++++++++++++----- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/home.admin/config.scripts/lnd.setport.sh b/home.admin/config.scripts/lnd.setport.sh index b7fb24689..e880f8208 100644 --- a/home.admin/config.scripts/lnd.setport.sh +++ b/home.admin/config.scripts/lnd.setport.sh @@ -29,6 +29,13 @@ 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 @@ -36,18 +43,35 @@ if [ ${lndConfExists} -eq 0 ]; then 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" \ No newline at end of file +# 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" \ No newline at end of file