What's new

New firmware version check - push notification

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

goaspy

New Around Here
Hi, is there a way to run a script that will send a Pushover notification whenever a new stable version is found?
I have the new version check option enabled, but I don't know if it's triggered by a web login or runs periodically.
If it runs periodically then it should be able to trigger a custom script. The only complication I see in this case is to send the message only once, and the script would have to store a last notified version number somewhere.
Thanks
 
and for pushover well all you need is to add, tweak it your needs to fit the script instead of email it can send a push

Code:
function push {
   curl -s -F "token=YOUR_TOKEN_HERE" \
   -F "user=YOUR_USER_KEY_HERE" \
   -F "title=YOUR_TITLE_HERE" \
   -F "message=$1" https://api.pushover.net/1/messages.json
}

push "It worked\!"
 
There's a custom script that gets run on new firmware availability. It's documented in the Changelog, but I forgot to add it to the Wiki after that version went out of beta. Check the Changelog for more info. I also posted a sample GMail script in the 380.65 alpha thread here on the forums.
 
i could volunteer to do a updated sample with pushover and pushbullet notifications planning to do a personal script anyways then i can add it to the wiki
 
tested script :p based on Rmerlins sample script

Code:
#!/bin/sh
use_email="disabled"                                    # enabled / disabled (default: disabled)
use_pushbullet="disabled"                               # enabled / disabled (default: disabled)
use_pushover="disabled"                                 # enabled / disabled (default: disabled)

#Pushbullet/Pushover settings
pushbullet_token=""                                     # Your access token here (https://docs.pushbullet.com/)
pushover_token=""                                       # Your access token here (https://pushover.net/api)
pushover_username=""                                    # Pushover User ID (the user/group key (not e-mail address often referred to as USER_KEY)

# email settings
SMTP="smtp.gmail.com"
PORT="465"
USERNAME=""
PASSWORD=""

# Mail Enveloppe
FROM_NAME=""
FROM_ADDRESS=""
TO_NAME=""
TO_ADDRESS=""

### Do not change below
# Retrieve version
TMPVERS=$(nvram get webs_state_info)
VERS=${TMPVERS:5:3}.${TMPVERS:8:10}
ROUTER_IP=$(nvram get lan_ipaddr)

email_message () {
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 at $ROUTER_IP." >> /tmp/mail.txt
curl --url smtps://$SMTP:$PORT \
  --mail-from "$FROM_ADDRESS" --mail-rcpt "$TO_ADDRESS" \
  --upload-file /tmp/mail.txt \
  --ssl-reqd \
  --user "$USERNAME:$PASSWORD" --insecure
rm /tmp/mail.txt
}

pushover_message () {
curl -s \
  --form-string "token=$pushover_token" \
  --form-string "user=$pushover_username" \
  --form-string "message=New firmware version $VERS is now available for your router at $ROUTER_IP." \
  https://api.pushover.net/1/messages.json
}

pushbullet_message () {
text="New firmware version $VERS is now available for your router at $ROUTER_IP."
title="$USER@$HOSTNAME"
curl -s -u $pushbullet_token: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "'"$title"'", "body": "'"$text"'"}' >/dev/null 2>&1
}

     if [ $use_pushbullet = "enabled" ]; then
        pushbullet_message
     fi
     if [ $use_pushover = "enabled" ]; then
        pushover_message
     fi
     if [ $use_email = "enabled" ]; then
        email_message
     fi
 
Last edited:
Thanks for your help, I've got it working, at least manually for now, I just have to wait for a new release :)

I was getting this error at first, "curl: option -F: is badly used here", but I've changed it using an example from pushover and it works fine now:

Code:
pushover_message () {
curl -s \
  --form-string "token=$pushover_token" \
  --form-string "user=$pushover_username" \
  --form-string "message=New firmware version $VERS is now available for your router at $ROUTER_IP." \
  https://api.pushover.net/1/messages.json
}
 
One last thing, I've named the script "update-notification", as mentioned in the changelog, and I've placed it in "/jffs/scripts". I should now get notifications every 48h until I switch to the new version.

Cheers!
 

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