From telnetting in with putty
In my factory firmware I can issue
nvram show | grep jffs | sort -u
and get back this
jffs2_exec=
jffs2_on=1
While telnetted in, issue the command
nvram set jffs2_exec= /jffs/myscript.sh
then issue
nvram commit
so it will stay persistent after reboots and will be rerun at every boot.
While telnetted in, issue the command...
Speaking of dangerous, if your firmware supports telnet, you should disable it in the GUI and only use ssh. You can use putty to open an ssh session. I'm on Merlin and I no longer see a telnet option in the GUI. IDK if it is the same with ASUS firmware.I have provided enough information for you to be a danger to your system.
Speaking of dangerous, if your firmware supports telnet, you should disable it in the GUI and only use ssh. You can use putty to open an ssh session. I'm on Merlin and I no longer see a telnet option in the GUI. IDK if it is the same with ASUS firmware.
Also, unless you have a very real reason to modify your router's settings via internet, make sure it is set for LAN Only. There's a few more settings you can do to harden your router's security, but this is the main loophole.
nvram set jffs2_exec=/jffs/myscript.sh
then issue
nvram commit
so it will stay persistent after reboots and will be rerun at every boot.
$ ssh x.x.x.x
$ cat /jffs/scripts/dnsmasq.sh
#!/bin/sh
echo "test" > /jffs/scripts/test.txt
killall dnsmasq
dnsmasq --no-poll --log-async -c 1500
$ nvram show | grep jffs
jffs2_enable=1
jffs2_exec=/jffs/scripts/dnsmasq.sh
jffs2_format=0
jffs2_on=1
log_path=/jffs
$ reboot
$ ssh x.x.x.x
$ ls -la /jffs/scripts/
. .. dnsmasq.sh dnsmasq.sh.bac
$ ps | grep dns
1367 nobody 2364 S dnsmasq --log-async
1368 jwierzbo 2364 S dnsmasq --log-async
2613 jwierzbo 3096 S grep dns
dos2unix /jffs/scripts/dnsmasq.sh
chmod 755 /jffs/scripts/dnsmasq.sh
Maybe your script doesn't have the correct format or permissions?
Code:dos2unix /jffs/scripts/dnsmasq.sh chmod 755 /jffs/scripts/dnsmasq.sh
/jffs/scripts/dnsmasq.sh
nvram set script_usbmount="chmod 700 /jffs/*.sh;/jffs/myasusrouter.sh"
#!/bin/sh
# next line stops script if it has already been run since reboot
mkdir /tmp/asusrouterlock 2> /dev/null || exit
# the rest of the script....
I've checked it today and it doesn't not work on my RT-AC86U (with newest firmware: 3.0.0.4.386_40451).
Script is not executed after router restart:
Bash:$ ssh x.x.x.x $ cat /jffs/scripts/dnsmasq.sh #!/bin/sh echo "test" > /jffs/scripts/test.txt [B]killall dnsmasq[/B] dnsmasq --no-poll --log-async -c 1500 $ ps | grep dns 1367 nobody 2364 S dnsmasq --log-async 1368 jwierzbo 2364 S dnsmasq --log-async 2613 jwierzbo 3096 S grep dns
Did you reboot and see if the 'X' attrib is still set?
Asus had made some changes a while back and I'm not even sure if nvram set jffs2_exec still works.
The workaround uses a different nvram tag that lets us specify a command to be executed when a USB device is mounted. In this example, I have a script named /jffs/myasusrouter.sh which does some housekeeping and schedules my other scripts. But this requires that some USB storage device be mounted. If you don't currently use USB, just put a formatted memory stick in the port and leave it there. It will be detected every reboot.
Code:nvram set script_usbmount="chmod 700 /jffs/*.sh;/jffs/myasusrouter.sh"
Since a USB mount can happen during normal operation, it is wise to put some defensive logic in your script to prevent the guts from running multiple times.
So myasusrouter.sh starts with:
Code:#!/bin/sh # next line stops script if it has already been run since reboot mkdir /tmp/asusrouterlock 2> /dev/null || exit # the rest of the script....
BTW. this method does not interfer with Merlin scripts, if you should ever care to switch. But there are cleaner ways to run scripts under Merlin.
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!