How to have AiMesh Node run a script once it has an internet connection?

Rocketboy235

Occasional Visitor
Hello,

I'm trying to figure out the best way to automatically execute the script on the AiMesh node as soon as it connects to the primary router and then has a connection to the internet.
I was looking around on the forums and trying to research but unfortunately nothing came up for me.

I am wondering if I can make use of wan-start or wan-event that is (since wan-start is deprecated). I then wondered if the AiMesh node would execute wan-event scripts since it isn't the primary router so I checked the wan IP address on the nodes and it came back as 0.0.0.0 so I'm not sure if that option would work. Not sure if there is another option out there that I can consider to automatically execute the script as soon as an internet connection is established for the node. I have a script setup for my main router. Another added benefit is if I get emails from both router and nodes at the same time, I'll know that it might be a power outage or modem issue and not solely a router/node issue.

Reason for doing this is so it can help me determine if the node crashes, or just simply loses connection (since it is not always stable) so I just want to gather some metrics.

Thanks for any help offered!
 

eibgrad

Part of the Furniture
As long as the router will recognize the init-start script, that should be sufficient. In my own case, I always send an email to myself anytime the router is rebooted. I just create a loop in the init-start script that checks for internet connectivity, then attempts to send the email.

Bash:
#!/bin/sh

# wait for *reliable* internet connection
until ping -qc1 -w3 8.8.8.8 &>/dev/null; do sleep 10; done; sleep 10

# do something
...
 

rlj2

Senior Member
As long as the router will recognize the init-start script, that should be sufficient. In my own case, I always send an email to myself anytime the router is rebooted. I just create a loop in the init-start script that checks for internet connectivity, then attempts to send the email.

Bash:
#!/bin/sh

# wait for *reliable* internet connection
until ping -qc1 -w3 8.8.8.8 &>/dev/null; do sleep 10; done; sleep 10

# do something
...
Same thing here, but uses cron, just with email and text message.


#!/bin/sh
# Use the following carrier domain email relays to send a SMS instead of email [email protected]
# Wireless Carrier Domain Name
# At&T @txt.att.net
# Cricket @mms.mycricket.com
# Nextel @messaging.nextel.com
# Qwest @qwestmp.com
# Sprint @messaging.sprintpcs.com
# T-Mobile @tmomail.net
# US Cellular @email.uscc.net
# Verizon @vtext.com
# Virgin @vmobl.com
#
# add "cru a linetest "0 * * * * /jffs/scripts/linetest" to /jffs/scripts/post-mount so it will run every hour

DATE=$(date)
ping -c 3 8.8.8.8 > /dev/null 2>&1

if [[ $? -ne 0 ]]
then
#setup msmtp
echo "Subject: Network DOWN - $DATE!" | msmtp -a default [email protected]
#sends me a text through verizon
echo "Subject: Network DOWN - $DATE!" | msmtp -a default [email protected]
echo "Network Down - $DATE!" >> /tmp/network.status

fi
 

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top