Browse Source

#312 localIP as placeholder if publiIP not available

dev
rootzoll 6 years ago
parent
commit
140c82ad01
  1. 13
      home.admin/40addHDD.sh
  2. 6
      home.admin/90finishSetup.sh
  3. 9
      home.admin/_bootstrap.sh
  4. 2
      home.admin/assets/lnd.service

13
home.admin/40addHDD.sh

@ -50,6 +50,8 @@ if [ ${existsHDD} -gt 0 ]; then
configFile="/mnt/hdd/raspiblitz.conf"
configExists=$(sudo ls ${configFile} | grep -c 'raspiblitz.conf')
if [ ${configExists} -eq 0 ]; then
# create file and use init values from raspiblitz.info
source /home/admin/_version.info
sudo touch $configFile
sudo chmod 777 ${configFile}
@ -58,6 +60,17 @@ if [ ${existsHDD} -gt 0 ]; then
echo "network=${network}" >> $configFile
echo "chain=${chain}" >> $configFile
echo "hostname=${hostname}" >> $configFile
# try to determine publicIP and if not possible use localIP as placeholder
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
if [ ${#freshPublicIP} -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 yet - working with placeholder : ${localIP}"
freshPublicIP="${localIP}"
fi
echo "publicIP=${freshPublicIP}" >> $configFile
fi
# move SSH pub keys to HDD so that they survive an update

6
home.admin/90finishSetup.sh

@ -73,12 +73,6 @@ echo "enable lazy firewall"
sudo ufw --force enable
echo ""
# set raspi config as environment for lnd service
sudo systemctl stop lnd
sudo systemctl disable lnd
sudo sed -i "s/^EnvironmentFile=.*/EnvironmentFile=\/mnt\/hdd\/raspiblitz.conf/g" /etc/systemd/system/lnd.service
sudo systemctl enable lnd
# update system
echo ""
echo "*** Update System ***"

9
home.admin/_bootstrap.sh

@ -288,6 +288,15 @@ if [ ${configExists} -eq 1 ]; then
# wait otherwise looking for publicIP fails
sleep 5
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
if [ ${#freshPublicIP} -eq 0 ]; then
# 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
freshPublicIP="${localIP}"
fi
fi
if [ ${#freshPublicIP} -eq 0 ]; then
echo "WARNING: Was not able to determine external IP on startup." >> $logFile
else

2
home.admin/assets/lnd.service

@ -9,7 +9,7 @@ After=bitcoind.service
#OnFailure=systemd-sendmail@%n
[Service]
EnvironmentFile=
EnvironmentFile=/mnt/hdd/raspiblitz.conf
ExecStart=/usr/local/bin/lnd --externalip=${publicIP}
PIDFile=/home/bitcoin/.lnd/lnd.pid
User=bitcoin

Loading…
Cancel
Save