Hi friends, I know this may be asked a couple of times, but online resources didn't help.
I have an unconventional openwrt install (a porting of openwrt on a telco router) which I configured for my needings and now working fine. Now I would like to come back at this point when I press the reset button on the back of my router. As I can not build a custom openwrt build because of my situation the only option is to change the rc.button script to get some other things done but unfortunately changes to /etc/rc.button/reset does not make much. I'll explain better
To test the behavior of the reset script, I added a mkdir /home/itworked && after the reset script. This is how reset script looked after the change
if I vi /etc/rc.button/reset and reboot the router my change is kept in the file but as I reset the router, the original untouched reset file is restored without any changes made and without making dir itworked in home. I know that openwrt is an overlay filesystem but why my command isn't executed for the first time either?
Is there something I can do to append a custom .sh script after the jiffs2reset and make this work?
Why don't you keep your working config in /etc/backup (just copy the /etc/config folder to /etc/backup) and modify the reset button script to copy from backup to config instead of jffs2reset?
sysupgrade -b and sysupgrade -r could be of use here.
Note that these do not completely return to original configuration, since packages that have been installed or files added outside of the sysupgrade "keep" system will not be deleted.
Could also work to tar up the whole /overlay/upper tree then delete and restore it. You also want the tar file with the original settings to survive this process so that it can be done more than once.
@vgaetera I already read this but it says just how to add a button and not how to change behavior of an existing one. Also I don't understand how the Hardware-level gpio pin triggering is linked to the button name. Is it just BTN_0 the HWID of the reset button? In this case, creating a new button as the tutorial says with the name BTN_0 and with my script as header should work. Is this the case?
ok @vgaetera just tried sending this commands one by one but still don't work, it resets deleting everything as usual
uci add system button
uci set system.@button[-1].button="BTN_0"
uci set system.@button[-1].action="released"
uci set system.@button[-1].handler="mkdir /home/itworked"
uci set system.@button[-1].min="5"
uci set system.@button[-1].max="30"
uci commit system
@mk24
As I said some posts ago, changing /etc/rc.button/reset script doesn't work in any way. Almost sure that when I push the reset button that's not called either. Even if I delete it, it still resets. That script is no use
Button name is BTN_0 as I read from logread and the button we're talking about is reset. Router is Telstra tg789vac v2 with rooted firmware based on Chaos Calmer 15.02
Button handling etc. has changed somewhat during the years, so the advice given for current firmware versions may be different than the suitable advice for the ancient CC 15.05 (there is no 15.02).
With that old firmware, the esiest thing might be to copy the /etc/rc.button/reset script to be /etc/rc.button/BTN_0 script (and I think that it needs to be chmodded executable, also).
The problem is that, even if I remove completely the reset file on that folder, reset works as usual. So I think that's not the script we're looking for. It should be somewhere else
This worked! I found out that the button header was on /etc/config/button
And this approach is useful for searching other keywords too! Thanks for this @vgaetera