Emanuel Paul
Occasional Visitor
Hello
I started already a thread with this item. The way a member of this forum tried to help me was friendly in the beginning, but became offensive and insulting at the end...
So I hope to find other helpful users because I think that I'm just a small step away from the solution.
With the help out of the first thread I have the following set up now:
in directory "/jffs/scripts" (called ChkVPNIP.sh):
in directory "/jffs/scripts/init-start" (called cronjobs.sh):
The ChkVPNIP.sh works. I tested it manually. That's the reason why there is a SendMail even if the public IP is found. When everything works like I want, I will delete this line.
The problem is now, that cronjobs.sh is not executed every 15 minutes.
Would be very nice, if someone could tell me, how to fix that.
I started already a thread with this item. The way a member of this forum tried to help me was friendly in the beginning, but became offensive and insulting at the end...
So I hope to find other helpful users because I think that I'm just a small step away from the solution.
With the help out of the first thread I have the following set up now:
in directory "/jffs/scripts" (called ChkVPNIP.sh):
Code:
#!/bin/sh
VER="v1.01b"
#=========================================================================
#
# Check Public WAN IP of the VPN Client
#
# ChkVPNIP { 'vpn_client_id' } [ curl ]
#
# ChkVPNIP 1
# Check status of VPN Client 1 using 'STUN' method
# ChkVPNIP 1 curl
# Check status of VPN Client 1 using 'curl' method
SendMail(){
FROM="xxxxxxxx"
AUTH="xxxxxxxx"
PASS="xxxxxxxx"
FROMNAME="RT-AC86U"
TO="xxxxxxxx"
echo "Subject: Public IP 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 lost my public IP on OpenVPN." >>/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
return 0
}
#=====================================Main==============================
VPN_ID=$1
VPN_WANIP=
echo -e
logger -st "($(basename $0))" $$ $VER "VPN Public WAN IP checker....."
echo -e
if [ ! -z "$1" ];then
if [ "$(nvram get "vpn_client"$VPN_ID"_state")" == "2" ];then
if [ "$2" != "curl" ];then
if [ -f /usr/sbin/gettunnelip.sh ];then
sh /usr/sbin/gettunnelip.sh ${VPN_ID}
VPN_WANIP="$(nvram get vpn_client${VPN_ID}_rip)"
fi
fi
if [ -z "$VPN_WANIP" ];then
VPN_WANIP=$(curl --connect-timeout 5 -s --interface "tun1"${VPN_ID} "http://ipecho.net/plain")
fi
if [ -z "$VPN_WANIP" ];then
logger -st "($(basename $0))" $$ "VPN Client" $VPN_ID "lost it's public WAN IP address"
SendMail
else
logger -st "($(basename $0))" $$ "VPN Client" $VPN_ID "public WAN IP is" $VPN_WANIP
SendMail # <<===== Temporarily add this line =====
fi
else
echo -e "\a"
logger -st "($(basename $0))" $$ "***ERROR*** VPN Client" $VPN_ID "isn't connected!"
fi
else
echo -e "\a"
logger -st "($(basename $0))" $$ "***ERROR*** Missing arg1 vpn_id e.g. 1,2,3,4 or 5"
fi
echo -e
exit 0
in directory "/jffs/scripts/init-start" (called cronjobs.sh):
Code:
#!/bin/sh
cru a CheckVPNIP "15 * * * * /jffs/scripts/ChkVPNIP.sh"
The ChkVPNIP.sh works. I tested it manually. That's the reason why there is a SendMail even if the public IP is found. When everything works like I want, I will delete this line.
The problem is now, that cronjobs.sh is not executed every 15 minutes.
Would be very nice, if someone could tell me, how to fix that.