General TC > General TC Talk
Tiny Core get router IP on boot
(1/1)
nygauk:
Hi
I connect to my remote network using DDNS over the Internet, SSH and Putty. I have a Tiny Core box and a broadband router on that network. Everything works well.
I would like to pause the boot process of my remote Tiny Core box which boots at the same time as the broadband router, until the latter is fully up so I can get it's public IP address which is emailed to me by the Tiny Core box.
Here are the relevant lines in my bootlocal.sh:
--- Code: ---.
.
/opt/eth0.sh &
.
until /usr/bin/nc -z 192.168.1.1 80
do
echo "Router is not up yet. Waiting..." >> /home/tc/mail.txt
sleep 5
done
.
/usr/local/bin/curl ifconfig.me >> /home/tc/mail.txt
echo -n " on " >> /home/tc/mail.txt
sleep 30
date >> /home/tc/mail.txt
/usr/local/bin/curl --url smtp://<smtp server>:587 --ssl-reqd --mail-from me@my_email.com --mail-rcpt my_email@gmx.com --upload-file /home/tc/mail.txt --user <from@my_email.com:mypass>
.
.
--- End code ---
If I merely reboot the Tiny Core box remotely via SSH everything is fine. However, If I shut down the router and switch it on again (using an sms switch) at the same time as the Tiny Core box boots, it doesn't work, i.e. the date is not written to mail.txt and no email is sent.
I tried to use cron with the @reboot directive but that doesn't seem to do anything in Tiny Core.
Also it would be quite acceptable to get the router address after the boot up process but I can't see how to achieve this so that there is only one check soon after boot.
Any ideas would be greatly appreciated - thanks.
[EDIT]: Added code tags. Rich
curaga:
Add echos to a log file between each step, to find out which step is failing to proceed. Then save that command's errors to the log file.
Rich:
Hi nygauk
Welcome to the forum.
Please use Code Tags when posting commands and responses seen in a terminal. To use Code Tags click on the # icon
above the reply box and paste your text between the Code Tags as shown in this example:
--- Quote ---[code][ 36.176529] pcm512x 1-004d: Failed to get supply 'AVDD': -517
[ 36.176536] pcm512x 1-004d: Failed to get supplies: -517
[ 36.191753] pcm512x 1-004d: Failed to get supply 'AVDD': -517[/code]
--- End quote ---
It will appear like this in your post:
--- Code: ---[ 36.176529] pcm512x 1-004d: Failed to get supply 'AVDD': -517
[ 36.176536] pcm512x 1-004d: Failed to get supplies: -517
[ 36.191753] pcm512x 1-004d: Failed to get supply 'AVDD': -517
--- End code ---
Code Tags serve as visual markers between what you are trying to say and the information you are posting. They also preserve
spacing so column aligned data displays properly. Code tags also automatically add horizontal and or vertical scrollbars
to accommodate long lines and listings.
Rich:
Hi nygauk
I suspect your problem might be here:
--- Quote from: nygauk on December 17, 2023, 03:42:27 PM --- ...
--- Code: ---.
.
/opt/eth0.sh &
.
until /usr/bin/nc -z 192.168.1.1 80
----- Snip -----
--- End code ---
...
--- End quote ---
See if waiting until your network card is up helps:
--- Code: ---.
.
/opt/eth0.sh &
# Wait for network to come up
SEC="60"
while [ $SEC -gt 0 ]
do
SEC=$(($SEC - 1))
ifconfig | grep -q "Bcast:" && break
sleep 1
done
if [ $SEC -eq 0 ]
echo " ----- Network is not up. -----" >> /home/tc/mail.txt
fi
.
until /usr/bin/nc -z 192.168.1.1 80
----- Snip -----
--- End code ---
nygauk:
Hi everyone
As you indicated Rich, it did turn out to be a timing issue.
I have solved my problem by placing everything after the call to eth0.sh in bootlocal.sh into a separate script and calling this script from bootsync.sh after a sleep 300 (5 min for the router to come up). It now works fine.
Thanks for your prompt response and useful information (•‿•)
Navigation
[0] Message Index
Go to full version