mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-20 13:02:21 +02:00
set public_IP to local_ip if no PublicIP found on startup
This commit is contained in:
@@ -158,3 +158,6 @@ Allows you to automatically execute a custom script at the end of DietPi install
|
|||||||
Option 1 = Copy your script to /boot/Automation_Custom_Script.sh and it will be executed automatically.
|
Option 1 = Copy your script to /boot/Automation_Custom_Script.sh and it will be executed automatically.
|
||||||
Option 2 = Host your script online, then use AUTO_SETUP_CUSTOM_SCRIPT_EXEC=http://myweb.com/myscript.sh, it will be downloaded and executed automatically. | 0=disabled
|
Option 2 = Host your script online, then use AUTO_SETUP_CUSTOM_SCRIPT_EXEC=http://myweb.com/myscript.sh, it will be downloaded and executed automatically. | 0=disabled
|
||||||
NB: Executed script log /var/tmp/dietpi/logs/dietpi-automation_custom_script.log
|
NB: Executed script log /var/tmp/dietpi/logs/dietpi-automation_custom_script.log
|
||||||
|
|
||||||
|
### Guide to clone your SD-cards and shrink the image in linux:
|
||||||
|
https://beebom.com/how-clone-raspberry-pi-sd-card-windows-linux-macos/
|
@@ -283,16 +283,16 @@ if [ ${configExists} -eq 1 ]; then
|
|||||||
source ${configFile}
|
source ${configFile}
|
||||||
|
|
||||||
# update public IP on boot
|
# update public IP on boot
|
||||||
# wait otherwise looking for publicIP fails
|
|
||||||
sleep 5
|
|
||||||
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
|
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
|
||||||
if [ ${#freshPublicIP} -eq 0 ]; then
|
if [ ${#freshPublicIP} -eq 0 ]; then
|
||||||
echo "WARNING: Was not able to determine external IP on startup." >> $logFile
|
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}
|
||||||
else
|
else
|
||||||
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
|
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
|
||||||
if [ ${publicIPValueExists} -gt 1 ]; then
|
if [ ${publicIPValueExists} -gt 1 ]; then
|
||||||
# remove one
|
# remove one
|
||||||
echo "more then one publiIp entry - removing one" >> $logFile
|
echo "more then one publicIp entry - removing one" >> $logFile
|
||||||
sed -i "s/^publicIP=.*//g" ${configFile}
|
sed -i "s/^publicIP=.*//g" ${configFile}
|
||||||
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
|
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
|
||||||
fi
|
fi
|
||||||
|
@@ -8,7 +8,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
User=root
|
User=root
|
||||||
Group=root
|
Group=root
|
||||||
Type=simple
|
Type=oneshot
|
||||||
RemainAfterExit=true
|
RemainAfterExit=true
|
||||||
ExecStart=/home/admin/_bootstrap.sh
|
ExecStart=/home/admin/_bootstrap.sh
|
||||||
StandardOutput=journal
|
StandardOutput=journal
|
||||||
|
Reference in New Issue
Block a user