What's new
  • 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!

Collection of scripts for stock firmware

jacklul

Senior Member
I never actually made a thread for this, even though it's been in the wild for quite some time:

This is my collection of scripts for routers running stock firmware to extend functionality.

Most of the scripts were made because, well... I needed to solve specific problems and there was no Asuswrt-Merlin firmware for my device at that time.
Some scripts are based on existing guides or someone else's work - I always link back to the original resource in the script header.
Almost everything was tested on my AX58U V2 running 3.0.0.4.388 firmware, some scripts might not work on older firmware or other models.

Notable scripts that implement (more or less) features known from Asuswrt-Merlin:

- custom-configs - custom config files for select services
- service-event - service-event-end functionality but based on parsing syslog, this script is mainly to improve reliability of other scripts as it can detect when firewall or network configuration is restarted, there is no way to handle events that do not log 'rc_service' tagged messages
- force-dns - forces specific DNS server for the whole LAN, similar to global DNS setting in DNS Director
- dynamic-dns - custom Inadyn configuration
- few VPN related scripts that add some things that VPN Director can do

For full list of scripts - check the README.

There's also extras section with sample configurations and extra scripts.
Most likely this workaround will also be needed to start the scripts at boot.
 
I'm reserving this for future use.
 
Recently added a new script: vpn-monitor - basically a copy of VPNMON but basic and limited
 
These do work on the current 3.0.0.6-102 firmware, at least on the RT-AX86U-PRO. Thanks so much!
 
Last edited:
Actually i just rebooted and the scripts did not auto-start. so maybe there is an issue with the newer firmware.
 
Actually i just rebooted and the scripts did not auto-start. so maybe there is an issue with the newer firmware.
Check the syslog, look for "Executing usb-mount-script" line. Also make sure the router actually mounted the storage device, some low quality USB sticks can sometimes fail to mount and require replugging.
 
Check the syslog, look for "Executing usb-mount-script" line. Also make sure the router actually mounted the storage device, some low quality USB sticks can sometimes fail to mount and require replugging.
It does show usb-mount-script, but i don't see anything else log that is normally there when i manually start it. is that normal? I don't see any service-events logs
The usb stick is mounted.
 
Last edited:
It does show usb-mount-script, but i don't see anything else log that is normally there when i manually start it. is that normal? I don't see any service-events logs
The usb stick is mounted.
Does the /jffs/scripts/usb-mount-script exist and is executable?
Does it contain /jffs/scripts/jas.sh line?
Which scripts are you using?
Check 'cru -l' output to verify that the scripts didn't start (there won't by any entry for them there)
 
Does the /jffs/scripts/usb-mount-script exist and is executable?
Does it contain /jffs/scripts/jas.sh line?
Which scripts are you using?
Check 'cru -l' output to verify that the scripts didn't start (there won't by any entry for them there)
It does exist and is executabe
It does not contain the /jffs/scripts/jas.sh line
 
It does exist and is executabe
It does not contain the /jffs/scripts/jas.sh line
Try running "/jffs/scripts/jas.sh setup", that should re-add the line.
 
Try running "/jffs/scripts/jas.sh setup", that should re-add the line
That re-added the line. I'll restart it tonight to see if it works.
I'm using cron-queue, custom-configs, force-dns, service-event, temperature-warnings, uptime-reboot.
Thanks so much work working on this! Eventually I'll install Merlin, but these scrips are giving me almost everything I was using Merlin for.
 
Ok there is one thing I can't get to work. I'm trying to modify stubby which the custom-configs script says it can use the stubby.postconf to do so.
3006-102 now uses stubby-sdn.yml, so the file is /etc/stubby/stubby-0.yml
I've tried just about everything, i modified custom-configs.sh and changed it to /etc/stubby/stubby-0.yml in every location.

But stock doesn't have Merlin's /user/sbin/helper.sh so the script from this thread isn't working
Code:
#!/bin/sh
CONFIG=/etc/stubby/stubby-0.yml.new
source /usr/sbin/helper.sh
pc_replace "edns_client_subnet_private: 1" "edns_client_subnet_private: 0" $CONFIG

I just get /jffs/scripts/stubby-0.postconf: source: line 3: can't open '/usr/sbin/helper.sh'

I'm not sure what else to try. Maybe I'm not putting .new in the right place?
 
I just get /jffs/scripts/stubby-0.postconf: source: line 3: can't open '/usr/sbin/helper.sh'
/usr/sbin/helper.sh is only in Merlin firmware, you will have to either rewrite that script to use sed directly or download helper.sh from Merlin repository.

3006-102 now uses stubby-sdn.yml, so the file is /etc/stubby/stubby-0.yml
Does the /etc/stubby/stubby.yml still exist though ? Or is it only stubby-0.yml now? Are there multiple stubby processes running?
My script does not support multiple instances since it kills all of them and then restarts only one of them. In this particular case it might break your configuration.

If you only have one instance of stubby running you might be able to use stubby.postconf to modify /etc/stubby/stubby-0.yml directly (no .new) as long /etc/stubby/stubby.yml exists.
Remember to revert your modifications to custom-configs.sh.

You can also use custom-configs manually like this:
Code:
#!/bin/sh
# Add this script to cron and run it every minute or so
if ! grep -Fq "Modified by" /etc/stubby/stubby-0.yml; then
   /jffs/scripts/jas/custom-configs.sh modify /etc/stubby/stubby-0.yml
   # restart the process
fi
This will append /jffs/configs/stubby-0.yml.add and run /jffs/scripts/stubby-0.postconf but will NOT restart the process - you will have to do that yourself.
 
Last edited:
I only have one instance of stubby running since I don't have a dual WAN configured. So stubby-0.yml is the only file , stubby.yml doesn't exist on 3006.102.
 
I only have one instance of stubby running since I don't have a dual WAN configured. So stubby-0.yml is the only file , stubby.yml doesn't exist on 3006.102.
I've looked at the other thread, is stubby-0 stock firmware feature or Merlins? I think it was mentioned there to be Merlin only...
 
It's stock. 30006 uses stubby-sdn.yml because it supports separate dual wan configurations and separate VLANs "guest network pro". 802.1Q is now on the WAN page instead of the IPTV section so it can be different for the individual WANs
 
I don't think I will be able to support this in my script because of the reasons I mentioned earlier.
 
Expading the code I posted earlier, this might work:
Code:
#!/bin/sh
# save this as /jffs/scripts/stubby_sdn0.sh
# add this line to /jffs/scripts/usb-mount-script:
#  cru a stubby_sdn0 "*/1 * * * * /jffs/scripts/stubby_sdn0.sh"
# to disable after enabling:
#  cru d stubby_sdn0

if ! grep -Fq "Modified by" /etc/stubby/stubby-0.yml; then
    /jffs/scripts/jas/custom-configs.sh modify /etc/stubby/stubby-0.yml

    for pid in $(/bin/ps w | grep "[s]tubby" | grep -F "/etc/stubby/stubby-0.yml" | awk '{print $1}'); do
        kill -s SIGTERM "$pid" 2> /dev/null
        sleep 1
        kill -s SIGKILL "$pid" 2> /dev/null
        sleep 1
        cmdline="$(tr '\0' ' ' < "/proc/$pid/cmdline")"
        $cmdline && logger -st stubby_sdn0 "Restarted: $cmdline"
    done
fi
Updated to handle multiple pids
 
Last edited:
Just checking that your script handles this: there are two pids with that configuration running on my router. I'm not needing this, but I'd thought I'd let you know.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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