mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-10-09 20:32:52 +02:00
#283 detect if getting publi IP fails
This commit is contained in:
@@ -78,8 +78,12 @@ do
|
|||||||
echo "freshPublicIP(${freshPublicIP})"
|
echo "freshPublicIP(${freshPublicIP})"
|
||||||
echo "publicIP(${publicIP})"
|
echo "publicIP(${publicIP})"
|
||||||
|
|
||||||
|
if [ ${#freshPublicIP} -eq 0 ]; then
|
||||||
|
|
||||||
|
echo "freshPublicIP is ZERO - ignoring"
|
||||||
|
|
||||||
# check if changed
|
# check if changed
|
||||||
if [ "${freshPublicIP}" != "${publicIP}" ]; then
|
elif [ "${freshPublicIP}" != "${publicIP}" ]; then
|
||||||
|
|
||||||
# 1) update config file
|
# 1) update config file
|
||||||
echo "update config value"
|
echo "update config value"
|
||||||
|
@@ -279,19 +279,23 @@ if [ ${configExists} -eq 1 ]; then
|
|||||||
|
|
||||||
# update public IP on boot
|
# update public IP on boot
|
||||||
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
|
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
|
||||||
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
|
if [ ${#freshPublicIP} -eq 0 ]; then
|
||||||
if [ ${publicIPValueExists} -gt 1 ]; then
|
echo "WARNING: Was not able to determine external IP on startup." >> $logFile
|
||||||
# remove one
|
|
||||||
echo "more then one publiIp entry - removing one" >> $logFile
|
|
||||||
sed -i "s/^publicIP=.*//g" ${configFile}
|
|
||||||
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
|
|
||||||
fi
|
|
||||||
if [ ${publicIPValueExists} -eq 0 ]; then
|
|
||||||
echo "create value (${freshPublicIP})" >> $logFile
|
|
||||||
echo "publicIP=${freshPublicIP}" >> $configFile
|
|
||||||
else
|
else
|
||||||
echo "update value (${freshPublicIP})" >> $logFile
|
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
|
||||||
sed -i "s/^publicIP=.*/publicIP=${freshPublicIP}/g" ${configFile}
|
if [ ${publicIPValueExists} -gt 1 ]; then
|
||||||
|
# remove one
|
||||||
|
echo "more then one publiIp entry - removing one" >> $logFile
|
||||||
|
sed -i "s/^publicIP=.*//g" ${configFile}
|
||||||
|
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
|
||||||
|
fi
|
||||||
|
if [ ${publicIPValueExists} -eq 0 ]; then
|
||||||
|
echo "create value (${freshPublicIP})" >> $logFile
|
||||||
|
echo "publicIP=${freshPublicIP}" >> $configFile
|
||||||
|
else
|
||||||
|
echo "update value (${freshPublicIP})" >> $logFile
|
||||||
|
sed -i "s/^publicIP=.*/publicIP=${freshPublicIP}/g" ${configFile}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user