When I ran a manual check using the router’s web interface, it just said: “Temporarily unable to get the latest firmware information. Please try again later.” It doesn’t seem to be that temporary though.
TL;DR
The code is in this GitHub repo and the scheduling piece with cron is described a the end of this post.
To find the latest version, I just looked at the website, inspected the HTML, installed the packages request-promise and cheerio, and finally extracted the version number of interest.
In order to know if there is a new version since my last check, I of course need to keep track of what the version was the last time I checked. I did this with a simple text file on disk.
By sending a notification both when there is no update and when an error occurs, I won’t have any silent failures unless I made a mistake here somewhere.
import{getLatestStableVersion}from'./latest-version-checker.js';import{sendPushoverNotification}from'./notify.js';import{getLastCheckedVersion,saveLastCheckedVersion}from'./localFile.js';asyncfunctionmain(){try{constlastCheckedVersion=getLastCheckedVersion();console.log("main -> lastCheckedVersion",lastCheckedVersion)constlatestVersion=awaitgetLatestStableVersion();if(latestVersion!==lastCheckedVersion){constmessage=`🔔 New firmware version ${latestVersion} is now available at
https://www.asuswrt-merlin.net/`;sendPushoverNotification(message);saveLastCheckedVersion(latestVersion);}else{constmessage=`🤷♂️ No firmware released. ${latestVersion} is the latest.`;sendPushoverNotification(message);}}catch(error){console.log("main -> error",error)constmessage=`⚠️ Router firmware update check failed`;sendPushoverNotification(message);}}main();
Scheduling the update checker
I’m running this on a RaspberryPi and it’s scheduled to run once a week, 18:10 on Wednesdays. I found https://crontab.guru to be helpful for not mixing up the time settings.
The trickiest thing for me as a terrible Linux admin, was to get the cron scheduling working. Adding the output of echo $PATH at the top of the script did the trick. Logging the output (to router-update-check.log in this case), also helped.
router-update-check.sh script contains the following:
#!/bin/bash
PATH=/home/pi/.nvm/versions/node/v13.12.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/snap/bin
cd /home/pi/Code/asuswrt-merlin-update-check/
node ./main.js
The result of running the script once every minute (while troubleshooting) showed up in my phone like this. I now have an update checker that I can only blame myself if it doesn’t work. Great success!
No matching posts found. You can use wildcards and search only in titles, e.g. title:iot