Basically, system upgrade can be done with WebUI or CLI command.
But, I'm try to do auto test and upgrade firmware via curl.
I double check JSON-RPC interface, looks like no upgrade feature over there.
So, anyone have experience about if I want to upgrade firmware via curl, how can I do? Thanks.
But this would depend where the script is pointing to download the firmware (because you may run out of memory), it should be something like /tmp and then auto run the upgrade with:
sysupgrade -v /tmp/nefirmware.bin
I would suggest to add to the script a file checksum check first!
is there a reason, why SSH does not work for your automation? Millions of people already use SSH everyday non-interactively, to do stuff on remote machines.
You can run ssh on a custom different port too like 65542 or something. Or disable web interface on port 80 and place ssh there.
Using POST/GET to do firmware upgrade sounds like a lot of complexity for just a development device, and it isn't very safe for production systems either.
When someone finds the way to abuse that, they can remote-update your device firmware.
Breaking ssh with key authentication is much harder
I see you want to use curl to trigger luci-app-commands, I would recommend you look at the reverse possibility of using luci-app-commands to trigger curl
Personally I would use curl for the simple step of moving the new firmware image to the device
As for the actual sysupgrade, you can set a cron job to automatically attempt a sysupgrade every day at a certain time. If the file doesn't exist or cannot be verified, nothing happens. I do this on many of my boards.
30 4 * * * sysupgrade /tmp/firmware.bin
if you do it this way, all you need to worry about is getting the image to the device, and when you wake up next day it will be on the new image.
you can also create a cron job to download the image, then as long as you host the image with the same location and name it will be fully automated, the only downside would be waiting until the time you set
Thanks. If we have cloud service, yes, we would like to use cron table to do pull and firmware upgrade.
But, for auto testing, we prefer to use simple and active way to firmware upgrade.
Note that SSH signature is sent in plain text and can be easily detected at any transit host.
And transit hosts like routers can be compromised collecting data about SSH connections.
Also, key-based authentication cannot protect against open vulnerabilities.
Thus VPN as an independent layer of security is your best option.
My intuition still tells me that SSH providing shell access leads to a broader scope of concern.
This may be a false impression, but reading some CVE details can make you paranoid.
So, better safe than sorry and use SSH over VPN when possible.