From d2c9a110e1a1e29c998f8786c740456bf3678bb3 Mon Sep 17 00:00:00 2001 From: openoms Date: Tue, 12 Feb 2019 15:22:19 +0000 Subject: [PATCH] write local IP as a placeholder if no publicIP exists --- home.admin/_bootstrap.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index 05c5e66..87eab5b 100644 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -285,9 +285,16 @@ if [ ${configExists} -eq 1 ]; then # update public IP on boot freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php) if [ ${#freshPublicIP} -eq 0 ]; then - echo "WARNING: Was not able to determine external IP on startup. Setting publicIP to local_ip" >> $logFile - local_ip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') - sed -i "s/^publicIP=.*/publicIP=${local_ip}/g" ${configFile} + # prevent having no publicIP set at all and LND getting stuck + # https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101 + if [ ${#publicIP} -eq 0 ]; then + localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') + echo "WARNING: No publicIP information at all - working with placeholder: ${localIP}" >> $logFile + sed -i "s/^publicIP=.*/publicIP=${local_ip}/g" ${configFile} + fi + fi + if [ ${#freshPublicIP} -eq 0 ]; then + echo "WARNING: Was not able to determine external IP on startup." >> $logFile else publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' ) if [ ${publicIPValueExists} -gt 1 ]; then