It's related to any modern ASUS router with USB port: RT-N10U, RT-N13U, RT-N15U, RT-N16, RT-N56U, RT-N65U, RT-N66U, RT-AC66U. All those routers uses a stock firmware partially based on TomatoUSB code, so we may use a custom start/stop scripts to ignite external services from USB drive!
1. Start/Stop scripts.
There is a two script, which can be saved right into NVRAM:
2. Post-firewall rules.
Some services like a torrent client or SSH server needs an open port, so we need a script that will be executed after every applying of current firewall rules (e.g. in case of internet reconnection). A stock firmware got some limitation here but there is a way to open a port range:
3. USB hotplug script.
When firmware can't recognize an attached USB device, it may run a custom script to handle a new device. This my be useful to those who attaches a USB printer. I did not test this feature, but it looks good. Just save your usbplug-script to script_usbhotplug NVRAM variable, just like in #1.
1. Start/Stop scripts.
There is a two script, which can be saved right into NVRAM:
- one will be executed right after mounting every partition on boot,
- another will be executed right before dismounting partition before reboot.
If you'll run it once a two scripts will be saved: one — to start Entware/Optware services form USB HDD partition labeled MYPART, second — to shutdown it gracefully. Both scripts may survive reboot. All you have to do is to choose a partition to store Entware/Optware content and format it with MYPART label, for example:$ cat ./nvram.sh
#!/bin/sh
cat << EOF > /tmp/script_usbmount.tmp
if [ \$1 = "/tmp/mnt/MYPART" ]
then
ln -sf \$1 /tmp/opt
/opt/etc/init.d/rc.unslung start
fi
EOF
nvram set script_usbmount="`cat /tmp/script_usbmount.tmp`"
cat << EOF > /tmp/script_usbumount.tmp
if [ \$1 = "/tmp/mnt/MYPART" ]
then
/opt/etc/init.d/rc.unslung stop
fi
EOF
nvram set script_usbumount="`cat /tmp/script_usbumount.tmp`"
nvram commit
Please note: a stock firmware limits execution time for this script up to 3 seconds. If you need more time, I can show how to do it later.$ mkfs.ext3 -j -L MYPART /dev/sda1
2. Post-firewall rules.
Some services like a torrent client or SSH server needs an open port, so we need a script that will be executed after every applying of current firewall rules (e.g. in case of internet reconnection). A stock firmware got some limitation here but there is a way to open a port range:
It will be equal to following firewall rules:$ nvram set apps_dl_share=1
$ nvram set apps_dl_share_port_from=51413
$ nvram set apps_dl_share_port_to=51414
$ nvram commit
6881 UPD port will be opened in any case along with desired port range.iptables -I INPUT -p udp --dport 6881 -j ACCEPT
iptables -I INPUT -p udp --dport 51413:51414 -j ACCEPT
iptables -I INPUT -p tcp --dport 51413:51414 -j ACCEPT
3. USB hotplug script.
When firmware can't recognize an attached USB device, it may run a custom script to handle a new device. This my be useful to those who attaches a USB printer. I did not test this feature, but it looks good. Just save your usbplug-script to script_usbhotplug NVRAM variable, just like in #1.
Last edited: