What's new

amtm Email notification when there are updates?

  • 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!

LaMpiR

Regular Contributor
Hi good people.

I have managed to successfully edit my email settings, but I don't know if such thing is possible, that I get an email notification when there is an update to scripts which I am running? Instead of manually having to log in and check for updates with amtm.

Thank you very much in advance.
 
Yes, although it is a little confusing. At the moment you have to install Diversion, and then within its settings you can ask for a firmware update notification. That sends a weekly email if there is an update to the firmware, amtm, diversion, any of the installed scripts, or any entware packages. It would make sense for this to be in amtm.
 
Yes. Well, install diversion, then go into /opt/share/diversion/file and copy update-notification to /jffs/scripts. chmod 755 it so it will run. Try it to make sure it runs, then make a chron out of it. That will give you an email if there is an update.

Then uninstall diversion.
 
Last edited:
Hi!

Currently running asus-wrt merlin 384.13_10 on asus RT-AC3200

I did try your solution;
did install standard diversion 4.2.1 thru amtm 3.2.1
but I cannot find the /opt/var/share directory

also, I try to find, without success, the mentionned update-notification script under /jffs or the entware directory

Can you help ?

Thanks
1641331084604.png
 
but I cannot find the /opt/var/share directory
Oops, sorry: /opt/share/diversion/file. Corrected my post.

The update-notification script gets installed in that directory. I just suggested copying it to /jffs because it would get deleted when diversion is uninstalled.
 
wow!
this is a fast reply. I am impressed. thanks

still missing

# find /opt/share/diversion/file
/opt/share/diversion/file
/opt/share/diversion/file/mount-entware.div
/opt/share/diversion/file/ash-history.div
/opt/share/diversion/file/functions.div
/opt/share/diversion/file/helper.div
/opt/share/diversion/file/install.div
/opt/share/diversion/file/webui.zip
/opt/share/diversion/file/post-conf.div
/opt/share/diversion/file/rc.func.div
/opt/share/diversion/file/rotate-logs.div
/opt/share/diversion/file/S80pixelserv-tls
/opt/share/diversion/file/update-bl.div
/opt/share/diversion/file/write-config.div
 
Hmm. I wonder if I have this as a hangover from an earlier install, like years ago.

Here it is; you could create the file in /jffs, chmod it and see if it runs.
Code:
#!/bin/sh
#bof

# Diversion is free to use under the GNU General Public License version 3 (GPL-3.0)
# https://opensource.org/licenses/GPL-3.0

# Proudly coded by thelonelycoder
# Copyright (c) 2016-2066 thelonelycoder - All Rights Reserved
# https://www.snbforums.com/members/thelonelycoder.25480/
# https://diversion.ch

# Script Version 4.2.1

# This is an Diversion script that sends a notification
# email when a new firmware is available for this router

if [ -f /jffs/addons/amtm/mail/email.conf ]; then
    . /jffs/addons/amtm/mail/email.conf

    TEMPVERS=$(nvram get webs_state_info)

    if [ "$(echo "$(nvram get buildno)" | grep "380")" ]; then
        STABLEVERS=${TEMPVERS:5:3}.${TEMPVERS:8:10}
    else
        if echo $TEMPVERS | grep -q 3004_; then
            STABLEVERS=$(echo $TEMPVERS | sed 's/3004_//')
        else
            STABLEVERS=$TEMPVERS
        fi
    fi

    FROM_NAME="Diversion Router Firmware notification"
    [ -z "$(nvram get odmpid)" ] && routerModel=$(nvram get productid) || routerModel=$(nvram get odmpid)
    [ -z "$FRIENDLY_ROUTER_NAME" ] && FRIENDLY_ROUTER_NAME=$routerModel

    echo "From: \"$FROM_NAME\" <$FROM_ADDRESS>" >/tmp/divmail-body
    echo "To: \"$TO_NAME\" <$TO_ADDRESS>" >>/tmp/divmail-body
    echo "Subject: $FRIENDLY_ROUTER_NAME Router Asuswrt-Merlin new firmware notification" >>/tmp/divmail-body
    echo "Date: $(date -R)" >>/tmp/divmail-body
    echo >>/tmp/divmail-body
    echo "Hey there!" >>/tmp/divmail-body
    echo >>/tmp/divmail-body
    if [ "$1" = test ]; then
        echo "Note: This is a firmware update notification test, the output below may not be correct." >>/tmp/divmail-body
        echo >>/tmp/divmail-body
    fi
    echo "A new stable Asuswrt-Merlin firmware is available for your $FRIENDLY_ROUTER_NAME router at $(nvram get lan_ipaddr)." >>/tmp/divmail-body
    echo >>/tmp/divmail-body
    echo "Installed version: $(nvram get buildno)_$(nvram get extendno)" >>/tmp/divmail-body
    echo >>/tmp/divmail-body
    echo "Latest available stable version: $STABLEVERS" >>/tmp/divmail-body
    echo >>/tmp/divmail-body
    echo "See the changelog for what's new:" >>/tmp/divmail-body
    echo "For Asuswrt-Merlin 380.xx branch: https://asuswrt-merlin.net/changelog-380" >>/tmp/divmail-body
    echo "For Asuswrt-Merlin 382.xx/384.xx/386.xx branch: https://asuswrt-merlin.net/changelog" >>/tmp/divmail-body
    echo >>/tmp/divmail-body
    echo "Downloads are available at: https://asuswrt-merlin.net/download" >>/tmp/divmail-body
    echo >>/tmp/divmail-body
    echo "Very truly yours," >>/tmp/divmail-body
    echo "Your $FRIENDLY_ROUTER_NAME router (Model type $routerModel)" >>/tmp/divmail-body
    echo >>/tmp/divmail-body

    /usr/sbin/curl --url $PROTOCOL://$SMTP:$PORT \
        --mail-from "$FROM_ADDRESS" --mail-rcpt "$TO_ADDRESS" \
        --upload-file /tmp/divmail-body \
        --ssl-reqd \
        --user "$USERNAME:$(/usr/sbin/openssl aes-256-cbc $emailPwEnc -d -in /jffs/addons/amtm/mail/emailpw.enc -pass pass:ditbabot,isoi)" $SSL_FLAG

    if [ "$?" = "0" ]; then
        logger -t Diversion "sent firmware notification"
    else
        logger -t Diversion "was unable to send firmware notification, check settings"
    fi
    rm -f /tmp/divmail*

else
    logger -t Diversion "was unable to send firmware notification, email.conf not found"
fi
#eof
 
Again, thank you for your reply

When running, it sent me the following email:

Hey there!
A new stable Asuswrt-Merlin firmware is available for your asus router at 192.168.1.1.
Installed version: 384.13_10
Latest available stable version: 384_13_10
...cut...

As you can see, it wrongly state that there is a newer version of merlin!!

Also, by taking a look at the script, it does not seems to check for update to
"firmware, amtm, diversion, any of the installed scripts, or any entware packages."

Maybe another script ?

Thanks
 
I had a similar script with contains:

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)
if [ "$CUR_VERS" != "$VERS" ] ; then
...cut...
 
Again, thank you for your reply

When running, it sent me the following email:



As you can see, it wrongly state that there is a newer version of merlin!!

Also, by taking a look at the script, it does not seems to check for update to
"firmware, amtm, diversion, any of the installed scripts, or any entware packages."

Maybe another script ?

Thanks
Two things. The update email for amtm, diversion, etc. is diversion, specifically /opt/share/diversion/file/update.div. I don't know what happens if you run that without diversion installed.

Second, yes, I see when I run it I too get the "_" in place of the "." that triggers the update notice. I suppose you could get a weekly email and just ignore the spurious ones, or you could correct it, or you could run diversion.

@thelonelycoder, I'm making a hash of this mostly because it's been years since I first dug into this. Are you planning on moving this to amtm, or did you already?
 
Gents, the amtm send email when updates are available is in the planning.
 
I whipped this script up a few years ago to check for script updates. I add a cron job to run the script everyday at 1000.

Code:
#!/bin/sh

readonly MAILFILE="/tmp/update_file.txt"
readonly AMTMCHECKFILE="/tmp/amtm-tpu-check"

if [ -f $AMTMCHECKFILE ]; then rm $AMTMCHECKFILE; fi

amtm tpu

UPDATE="No"

if [ -f $AMTMCHECKFILE ] || [ "$UPDATE" = "Yes" ]; then
    echo "The following updates have been reported by AMTM/Cake-QoS" > $MAILFILE
    echo "" >> $MAILFILE
    if [ -f $AMTMCHECKFILE ]; then
        cat $AMTMCHECKFILE >> $MAILFILE
    fi

    if [ "$UPDATE" = "Yes" ]; then   
        echo "Updates to Cake-QoS are available" >> $MAILFILE
    fi

    echo "" >> $MAILFILE
    echo "Check for updates done on $(date -R)" >> $MAILFILE
    
    if [ -f $AMTMCHECKFILE ]; then rm $AMTMCHECKFILE; fi
    
    /jffs/addons/young/smail.sh $MAILFILE "AMTM: Script Updates are available"
fi

smail.sh is my general purpose script that I use to email me when required.
 
And this is my smail.sh script. I use it as a general purpose email script. Called for a variety of reasons. Looking forward to the @thelonelycoder implementation.

Code:
#!/bin/sh

# Send mail alert to administrator
#
# usage:
#    smail.sh text_body subject_line <recipients>

FROM="Sender Email"
AUTH="UserID"
PASS="GMAIL APP PASSWORD"
FROMNAME="Sender Long Name"

if ! [ $# -ge 2 ] && [ $# -le 3 ]
then
    printf "Not enough Arguments\n\n"
    printf "Usage: smail.sh <email_body> <subject_line> <address>\n\n"
    exit
fi

if ! [ -e $1 ]
then
    printf "File %s does not exit\n\n" $1
    exit
fi

if [ $# -eq 3 ]; then
    TO=$3
else
    TO="default email address to send to"
fi

echo "Subject: "$2 >/tmp/mail.txt
echo "From: $FROMNAME <$FROM>" >>/tmp/mail.txt
echo "Date:  $(date -R)" >>/tmp/mail.txt

cat $1 >>/tmp/mail.txt

echo "" >>/tmp/mail.txt

cat /tmp/mail.txt | /usr/sbin/sendmail  \
    -H "exec openssl s_client -quiet \
    -starttls smtp \
    -connect smtp.gmail.com:587  \
    -no_ssl3 -no_tls1" \
    -f "$FROM" -au"$AUTH" -ap"$PASS" "$TO" -v

rm /tmp/mail.txt
 
@thelonelycoder You also have my +1 vote for this implementation. Thanks in advance.
 

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!
Top