What's new

Need A little help with Openvpn-event script

Anshur

New Around Here
Hi everyone,

I'm trying to make my ASUS RT-AC68U send an email/IFTTT trigger every time my OpenVPN connexion connect or disconnect (client side, not server).

However, I can seem to get my head around up/down triggers for an openvpn-event script.

I've manage to make two functionning email scripts (up & down):
Code:
#!/bin/sh
echo "Subject: #OpenVPNConnect" >/tmp/mail.txt
echo "Content-Type: text/html" >>/tmp/mail.txt
echo "From: ASUS RT-AC68U" >>/tmp/mail.txt
echo "Date: `date -R`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "ASUS RT-AC68U has sucessufly connected to OpenVPN" >>/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"smtp.gmail.com"  -au"mylogin" -ap"mypassword" [email protected]

rm /tmp/mail.txt
Code:
#!/bin/sh
echo "Subject: #OpenVPNDisconnect" >/tmp/mail.txt
echo "Content-Type: text/html" >>/tmp/mail.txt
echo "From: ASUS RT-AC68U" >>/tmp/mail.txt
echo "Date: `date -R`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "ASUS RT-AC68U has been disconnected from OpenVPN" >>/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"smtp.gmail.com"  -au"mylogin" -ap"mypassword" [email protected]

rm /tmp/mail.txt

But I can't seem to find the correct synthax required to trigger them when my VPN goes down or up.

I tried to frankenstein something from another similar post i manage to found :
Code:
#!/bin/sh

#On openVPN connection

if [ $script_type == "up" -a $vpn_interface == "tun11" ];
then

sh /jffs/scripts/up.sh

fi

#On openVPN disconnection

if [ $script_type == "down" -a $vpn_interface == "tun11" ];
then

sh /jfss/scripts/down.sh

fi

But it doesn't seem to work. Any help would be welcome :)

ps: my coding skills are as basic as can be, so don't be afraid to dumb things down for me !
 
Similar threads
Thread starter Title Forum Replies Date
W I need some help with a new router and network card Routers 12
Z Router recommendation need. Routers 26

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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