asuswrt-scripts icon indicating copy to clipboard operation
asuswrt-scripts copied to clipboard

Collection of scripts that can run on stock Asus routers (also on Merlin's firmware and forks)

Custom scripts for AsusWRT

This uses known script_usbmount NVRAM variable to run "startup" script on USB mount event that starts things out.

Obviously this requires some kind of USB storage plugged into the router for this to work but you don't need it on Asuswrt-Merlin though - just start the scripts directly from services-start script.

If your router is not executing commands from script_usbmount NVRAM variable on USB mount - look here for a workaround.

Everything here was tested on RT-AX58U v2 on official 388.2 firmware - there is no guarantee that everything will work on non-AX routers and on lower firmware.
Some informations were pulled from GPL_RT-AX58U_3.0.0.4.388.22525-gd35b8fe sources.

A lot of scripts here are based on resources from SNBForums and asuswrt-merlin.ng wiki, big thanks to everyone who made those contributions to the community.

Installation

Install startup script:

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts-startup.sh" -o /jffs/scripts-startup.sh
/bin/sh /jffs/scripts-startup.sh install

If you would like for it to be called differently you can rename it (you can also place it different path if you wish).

Install scripts you want to use from section below.

Available scripts

conditional-reboot
cron-queue
custom-configs
disable-diag
disable-wps
dynamic-dns
entware
force-dns
guest-password
hotplug-event
led-control
modify-features
modify-webui
netboot-download
process-killer
rclone-backup
samba-masquerade
service-event
swap
temperature-warning
update-notify
update-scripts
usb-mount
usb-network
vpn-killswitch
wgs-lanonly

You can override config variables for scripts by creating .conf with the same base name as the script (for example: conditional-reboot.conf).
Configuration variables are defined on top of each script.

Remember to mark the scripts as executable after installing, you can do it in one command like this:

chmod +x /jffs/scripts/*.sh

conditional-reboot.sh

This script will reboot your router at specified time if it's been running for fixed amount of time.

By default, reboot happens at 5AM when uptime exceeds 7 days.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/conditional-reboot.sh" -o /jffs/scripts/conditional-reboot.sh

^ back to the list ^

cron-queue.sh

When running multiple scripts from this repository that run every minute via cron they can cause a CPU spike (and network wide ping spike on weaker devices).
This script will run all "every minute" tasks synchronously which will reduce the CPU load in exchange for task execution delays.

All scripts from this repository integrate with this script and will use it instead of cru when it's available.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/cron-queue.sh" -o /jffs/scripts/cron-queue.sh

^ back to the list ^

custom-configs.sh

This script implements Custom config files from Merlin firmware that allows you to use custom config files for certain services.

Supported config files
  • profile (profile.add only)
  • hosts
  • avahi-daemon.conf
  • dnsmasq.conf
  • igmpproxy.conf
  • minidlna.conf
  • mt-daapd.conf
  • pptpd.conf
  • smb.conf
  • snmpd.conf
  • stubby.yml (stubby.yml.add only)
  • vsftpd.conf
  • upnp config
Supported postconf scripts
  • hosts.postconf
  • avahi-daemon.postconf
  • dnsmasq.postconf
  • igmpproxy.postconf
  • minidlna.postconf
  • mt-daapd.postconf
  • pptpd.postconf
  • smb.postconf
  • snmpd.postconf
  • stubby.postconf
  • vsftpd.postconf
  • upnp.postconf

Keep in mind that for postconf scripts you have to reference .new in the file name instead (for example /etc/smb.conf.new), the correct file path will be passed as an argument to the script.

NOTE: Usage of Samba, FTP and Media services without any USB storage requires nvram set usb_debug=1.

Recommended to use service-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/custom-configs.sh" -o /jffs/scripts/custom-configs.sh

^ back to the list ^

disable-diag.sh

This script prevent conn_diag from (re)starting amas_portstatus which likes to hog the CPU sometimes.

No idea what conn_diag is itself, some kind of diagnostics utility...?

Do not install this script if you don't have mentioned CPU usage issue.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/disable-diag.sh" -o /jffs/scripts/disable-diag.sh

^ back to the list ^

disable-wps.sh

This script does exactly what you would expect - makes sure WPS stays disabled.

By default, runs check at boot and at 00:00, and when service-event.sh is used it also runs every time wireless is restarted.

Recommended to use service-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/disable-wps.sh" -o /jffs/scripts/disable-wps.sh

^ back to the list ^

dynamic-dns.sh

This script implements custom DDNS feature from Merlin firmware that allows you to use custom Inadyn config file.

Checks every minute for new IP in NVRAM variable wan0_ipaddr. You can alternatively configure it to use website API like "ipecho.net/plain".

On Merlin firmware you should call this script from ddns-start with force argument instead of start.

You might have to install Entware's curl to bypass the limitations of the firmware one.

Recommended to use service-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/dynamic-dns.sh" -o /jffs/scripts/dynamic-dns.sh

^ back to the list ^

entware.sh

This script installs and enables Entware, even in RAM (/tmp).

When installing to /tmp it will automatically install specified packages and symlink files from /jffs/entware to /opt. If you want to symlink whole directory then create .symlinkthisdir file in its root, be careful to not nest those and not symlink important directories like /opt/etc.

If you want to use HTTPS to download packages you might have to install Entware's wget-ssl and ca-certificates.

Recommended to use hotplug-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/entware.sh" -o /jffs/scripts/entware.sh

^ back to the list ^

force-dns.sh

This script will force specified DNS server to be used by LAN and Guest WiFi, can also prevent clients from querying the router's DNS server.

This script can be very useful when running Pi-hole in your LAN.

Recommended to use service-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/force-dns.sh" -o /jffs/scripts/force-dns.sh

^ back to the list ^

guest-password.sh

This script rotates Guest WiFi passwords.

By default, it rotates passwords for the first network pair at 4AM.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/guest-password.sh" -o /jffs/scripts/guest-password.sh

^ back to the list ^

hotplug-event.sh

This script handles hotplug events.

By default, integrates with all scripts present in this repository.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/hotplug-event.sh" -o /jffs/scripts/hotplug-event.sh

^ back to the list ^

led-control.sh

Warning: this script is not complete and will probably not work on stock firmware (should work on Merlin), see note in the script.

This script implements scheduled LED control from Merlin firmware.

By default, LEDs shutdown at 00:00 and turn on at 06:00.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/led-control.sh" -o /jffs/scripts/led-control.sh

^ back to the list ^

modify-features.sh

This script modifies rc_support NVRAM variable to enable/disable some features, this is mainly for hiding Web UI menus and tabs.

A good place to look for potential values are init.c and state.js files in the firmware sources.

Recommended to use service-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/modify-features.sh" -o /jffs/scripts/modify-features.sh

^ back to the list ^

modify-webui.sh

This script modifies some web UI elements.

Currently applied modifications:

  • display CPU temperature on the system status screen (with realtime updates)
  • show connect QR code on guest network edit screen and hide the passwords on the main screen
  • add notrendmicro rc_support option that hides all Trend Micro services, Speed Test will be moved to Network Tools menu (to be used with modify-features.sh)

Tested only with English language!

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/modify-webui.sh" -o /jffs/scripts/modify-webui.sh

^ back to the list ^

netboot-download.sh

Automatically download specified bootloader files from netboot.xyz.

This and custom-configs.sh can help you setup a netboot.xyz PXE server on the router.

You might have to install Entware's curl to bypass the limitations of the firmware one.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/netboot-download.sh" -o /jffs/scripts/netboot-download.sh

^ back to the list ^

process-killer.sh

This script can kill processes by their names, unfortunately on stock most of them will restart, there is an attempt to prevent that in that script but it is not guaranteed to work.

Use this script at your own risk.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/process-killer.sh" -o /jffs/scripts/process-killer.sh

^ back to the list ^

rclone-backup.sh

This script can backup all NVRAM variables and selected /jffs contents to cloud service using Rclone.

You have to download the binary and place it on the USB drive. If you installed it through the Entware then it will be automatically detected, alternatively it will install it when it detects Entware installation (then remove it after the job is done - this feature is targeted for installation in /tmp).

If automatic installation of rclone fails then you might have to install Entware's wget (or wget-ssl when using HTTPS) to bypass the limitations of the firmware one.

Example backup list that can be used with this script.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/rclone-backup.sh" -o /jffs/scripts/rclone-backup.sh

^ back to the list ^

samba-masquerade.sh

Enables masquerading for Samba ports to allow VPN clients to connect to your LAN shares.

By default, default networks for WireGuard, OpenVPN and IPSec are allowed.

Recommended to use service-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/samba-masquerade.sh" -o /jffs/scripts/samba-masquerade.sh

^ back to the list ^

service-event.sh

This script tries to emulate service-event script from Merlin firmware but there is no guarantee whenever it will run before or after the event.
Example custom script that can be used with this script.

By default, integrates with all scripts (when required) present in this repository.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/service-event.sh" -o /jffs/scripts/service-event.sh

^ back to the list ^

swap.sh

This script enables swap file on start, with configurable size and location.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/swap.sh" -o /jffs/scripts/swap.sh

^ back to the list ^

temperature-warning.sh

This script will send log message when CPU or WLAN chip temperatures reach specified threshold.

Be default, the treshold is set to 80C.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/temperature-warning.sh" -o /jffs/scripts/temperature-warning.sh

^ back to the list ^

update-notify.sh

This script will send you a notification when new router firmware is available.

Currently supported notification providers:

You might have to install Entware's curl to bypass the limitations of the firmware one.

You can test the notifications by using update-notify.sh test (if it works from the cron) and update-notify.sh test now (if it actually sends) commands.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/update-notify.sh" -o /jffs/scripts/update-notify.sh

^ back to the list ^

update-scripts.sh

This script updates all *.sh scripts present in the /jffs/scripts folder.

This is on-demand script that must be ran manually.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/update-scripts.sh" -o /jffs/scripts/update-scripts.sh

^ back to the list ^

usb-mount.sh

This script will mount any USB storage device in /tmp/mnt directory if for some reason the official firmware does not automount it for you.

Recommended to use hotplug-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/usb-mount.sh" -o /jffs/scripts/usb-mount.sh

^ back to the list ^

usb-network.sh

This script will add any USB networking gadget to LAN bridge interface, making it member of your LAN network.

This is a great way of running Pi-hole in your network on a Raspberry Pi Zero connected through USB port.

Recommended to use service-event.sh and hotplug-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/usb-network.sh" -o /jffs/scripts/usb-network.sh

^ back to the list ^

vpn-killswitch.sh

This script will prevent your LAN from accessing the internet through the WAN interface.

There might be a small window after router boots and before this script runs when you can connect through the WAN interface but there is no way to avoid this on stock firmware.

Recommended to use service-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/vpn-killswitch.sh" -o /jffs/scripts/vpn-killswitch.sh

^ back to the list ^

wgs-lanonly.sh

This script will prevent clients connected to WireGuard server from accessing the internet.

Recommended to use service-event.sh as well.

curl -fsSL "https://raw.githubusercontent.com/jacklul/asuswrt-scripts/master/scripts/wgs-lanonly.sh" -o /jffs/scripts/wgs-lanonly.sh