jtp10181
Senior Member
This works on firmware 380.65 +
Script goes in /jffs/scripts/ and must be executable
Script name is: update-notification
Somewhere in the release thread I think Merlin posted a sample script and I took that and tweaked it and made it more versatile. I thought it was to the point to be worth sharing. It works for an ISP SMTP server which often does not require a login because they can see you are on their network.
You just need to fill in the blanks in the top two sections, should be self explanatory.
NOTE: If you do not use SSL passwords are sent in plain text. I have it setup to always try SSL, but if you set ForceSSL="1" curl will halt if it cannot make a secure connection.
You can test if it works by manually executing the script from command line. And you also add -v to the end of the curl command to see verbose output while testing if you are having issues.
Script goes in /jffs/scripts/ and must be executable
Script name is: update-notification
Somewhere in the release thread I think Merlin posted a sample script and I took that and tweaked it and made it more versatile. I thought it was to the point to be worth sharing. It works for an ISP SMTP server which often does not require a login because they can see you are on their network.
You just need to fill in the blanks in the top two sections, should be self explanatory.
NOTE: If you do not use SSL passwords are sent in plain text. I have it setup to always try SSL, but if you set ForceSSL="1" curl will halt if it cannot make a secure connection.
You can test if it works by manually executing the script from command line. And you also add -v to the end of the curl command to see verbose output while testing if you are having issues.
Code:
#!/bin/sh
# SMTP parameters
SMTP="smtp.mailserver.com"
PORT="25"
ForceSSL="0"
USERNAME=""
PASSWORD=""
# Mail Enveloppe
FROM_NAME="$(nvram get computer_name) Router"
FROM_ADDRESS="from_email@mailserver.com"
TO_NAME="Your Name"
TO_ADDRESS="destination_email@whatever.com"
### Do not change below
# Retrieve version
VERS=$(nvram get webs_state_info | sed -E "s/.*([0-9]{3})_([0-9_]+?).*/\1.\2/")
ROUTER_IP=$(nvram get lan_ipaddr)
ROUTER_NAME=$(nvram get computer_name)
CUR_VERS=$(nvram get buildno)_$(nvram get extendno)
echo "From: \"$FROM_NAME\" <$FROM_ADDRESS>" > /tmp/mail.txt
echo "To: \"$TO_NAME\" <$TO_ADDRESS>" >> /tmp/mail.txt
echo "Subject: New router firmware notification" >> /tmp/mail.txt
echo "" >> /tmp/mail.txt
echo "New firmware version $VERS is now available for your router: $ROUTER_NAME / $ROUTER_IP" >> /tmp/mail.txt
echo "Current installed firmware version is: $CUR_VERS" >> /tmp/mail.txt
echo "" >> /tmp/mail.txt
echo "https://asuswrt.lostrealm.ca/" >> /tmp/mail.txt
if [ "$ForceSSL" == "1" ]; then
FSSL="--ssl-reqd --insecure"
fi
if [ "$USERNAME" != "" ]; then
USRPW="--user $USERNAME"
if [ "$PASSWORD" != "" ]; then
USRPW="$USRPW:$PASSWORD"
fi
fi
#Send email with cURL
curl --url "$SMTP:$PORT" --ssl $FSSL $USRPW \
--mail-from "$FROM_ADDRESS" --mail-rcpt "$TO_ADDRESS" \
--upload-file /tmp/mail.txt
#cat /tmp/mail.txt
rm /tmp/mail.txt
Last edited: