What's new

Is there a clear guide how to run custom scripts on Stock Firmware?

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

KnowsMuch

Occasional Visitor
I was hoping to do a couple things on the router that require custom scripts.
  1. Dropping login attempts to the OpenVPN server from specific IP Blocks
  2. Creating a Custom DDNS using NameCheap
Any advice would be appreciated.
 
Stock firmware doesn't support user scripts like Merlin does (i.e. firewall-start or openvpn-event).

I believe there's a way to trigger a script when the router starts up (using the USB mount event) but that's it.
 
On boot up, it runs a script named /jffs/.asusrouter (make sure it is executable. Beware that this seems to run early in the startup processing while other things are still firing-up. I've had unusual things happen. Basically, some things work and others don't. And some times things work that didn't before. Maddening!

I use it to add jobs to crontab, add lines to the hosts file, and other stuff.
 
Last edited:
I have started a swap file on a USB using a script in file: /jffs/post-mount You can put whatever you want in the script but it needs to begin with:
#!/bin/sh
and I would add a delay line next like:
sleep 5

To get it to work, in a terminal do:
nvram set script_usbmount="/jffs/post-mount"
nvram commit

When the router starts or you insert a USB drive the script will run.
 
I have started a swap file on a USB using a script in file: /jffs/post-mount You can put whatever you want in the script but it needs to begin with:
#!/bin/sh
and I would add a delay line next like:
sleep 5

To get it to work, in a terminal do:
nvram set script_usbmount="/jffs/post-mount"
nvram commit

When the router starts or you insert a USB drive the script will run.
If I understand this correctly, the /jffs/post-mount script would run every time a usb drive was inserted. I'm guessing that on a boot, if one or more usb drives were already connected, it would run for each? So for one-time changes, the script probably should use a lock file in /tmp/root (so it is cleared post reboot) or some other mechanism to prevent running again.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top