What's new

trigger (user script) for wan failover on Merlin

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

BaconScout

Occasional Visitor
HI, I am wanting to trigger an email on failover /failback of my dual wan.

Is someone doing this now and can share?

if not any suggestions on how to facilitate i was thinking /wan-start would be viable but I haven't dug into it yet.

thanks!
BaconScout.
 
To answer my own question. The info merlin posted on github for emails specifically gmail for the wan-start helped a lot.

A little help for anyone wanting to send an email to text /txt to tmobile phones tmo wont allow you to have a cc or bcc you can only send one email / txt to their phones. Because i wanted to send a txt to phone and an email to my inbox i just added an additional var for 'To' called 'TOTO" and then before the rm /tmp/mail.txt added another single sendmail for each; one for tmo and one for gmail;

-----

#!/bin/sh
sleep 10
FROM="mymail@gmail.com"
AUTH="mymail@gmail.com"
PASS="one off google apps password"
FROMNAME="AC68U"
TO="myctmocell@tmomail.net"
TOTO="mymail@gmail.com"

ntpclient -h pool.ntp.org -s &> /dev/null

echo "Subject: WAN state notification" >/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "From:" $FROMNAME "<$FROM>" >>/tmp/mail.txt
echo "" >>/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 wan0_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 -v -t -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 \

cat /tmp/mail.txt | sendmail -v -t -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" $TOTO \

rm /tmp/mail.txt

---
cheers
BaconScout
 
TO="myctmocell@tmomail.net"
TOTO="mymail@gmail.com"



cat /tmp/mail.txt | sendmail -v -t -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 \

cat /tmp/mail.txt | sendmail -v -t -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" $TOTO \

rm /tmp/mail.txt

---
cheers
BaconScout

So specifying multiple recipients in the 'TO=' variable using ', space' as the delimiter string

Code:
e.g.

TO="myctmocell@tmomail.net, mymail@gmail.com"


doesn't work? - forcing to you call sendmail for each email recipient?
 

Latest threads

Sign Up For SNBForums Daily Digest

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