lukeglazebrook
Occasional Visitor
I stole the below script and it works great, with the exception that I have tweaked it slightly in the hope that it will report my WAN2 USB address when a failover event occurs. I changed the highlighted bit below...
Unfortunately however I don't get a valid IP address when the email report arrives. Any idea why that might be?
#!/bin/sh
touch /tmp/want-start
FROM="luke@gmail.com"
AUTH="lukegmail.com"
PASS="********"
FROMNAME="RTAC88U ROUTER"
TO="luke@gmail.com"
ntpclient -h pool.ntp.org -s &> /dev/null
sleep 5
echo "Subject: WAN state notification" >/tmp/mail.txt
echo "From: \\"$FROMNAME\\"<$FROM>" >>/tmp/mail.txt
echo "Date: `date -R`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "I just got connected to the internet." >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "My WAN IP is: `nvram get usb0_ipaddr`" >>/tmp/mail.txt
echo "Uptime is: `uptime | cut -d ',' -f1 | sed 's/^.\{12\}//g'`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "---- " >>/tmp/mail.txt
echo "Your friendly router." >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
cat /tmp/mail.txt | sendmail -H"exec openssl s_client -quiet \
-CAfile /jffs/configs/Equifax_Secure_Certificate_Authority.pem \
-connect smtp.gmail.com:587 -tls1 -starttls smtp" \
-f"$FROM" \
-au"$AUTH" -ap"$PASS" $TO
rm /tmp/mail.txt
Unfortunately however I don't get a valid IP address when the email report arrives. Any idea why that might be? See example below...
"I just got connected to the internet.
My WAN IP is:
Uptime is: 0 min
----
Your friendly router."
Unfortunately however I don't get a valid IP address when the email report arrives. Any idea why that might be?
#!/bin/sh
touch /tmp/want-start
FROM="luke@gmail.com"
AUTH="lukegmail.com"
PASS="********"
FROMNAME="RTAC88U ROUTER"
TO="luke@gmail.com"
ntpclient -h pool.ntp.org -s &> /dev/null
sleep 5
echo "Subject: WAN state notification" >/tmp/mail.txt
echo "From: \\"$FROMNAME\\"<$FROM>" >>/tmp/mail.txt
echo "Date: `date -R`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "I just got connected to the internet." >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "My WAN IP is: `nvram get usb0_ipaddr`" >>/tmp/mail.txt
echo "Uptime is: `uptime | cut -d ',' -f1 | sed 's/^.\{12\}//g'`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "---- " >>/tmp/mail.txt
echo "Your friendly router." >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
cat /tmp/mail.txt | sendmail -H"exec openssl s_client -quiet \
-CAfile /jffs/configs/Equifax_Secure_Certificate_Authority.pem \
-connect smtp.gmail.com:587 -tls1 -starttls smtp" \
-f"$FROM" \
-au"$AUTH" -ap"$PASS" $TO
rm /tmp/mail.txt
Unfortunately however I don't get a valid IP address when the email report arrives. Any idea why that might be? See example below...
"I just got connected to the internet.
My WAN IP is:
Uptime is: 0 min
----
Your friendly router."
Last edited: