This is an old revision of the document!
Table of Contents
Install additional software
You can get a system for installing additional software by:
- plugging in a partitioned, ext4 formatted USB device
- enabling
Download Masteron that USB device
The Download Master installation mounts a subdirectory on the USB device to opt/bin and it fetches a bunch of packages including ipkg, the same tool that manages packages on OpenWRT.
Entware
Entware is a repository of prebuilt packages that can be installed on the USB device.
wget -O - http://bin.entware.net/aarch64-k3.10/installer/generic.sh | sh
Using a standard init.d startup script system services can be launched on boot.
How a script is started at boot (asusware.arm mechanism)
We use the app mechanism that Download Master/Optware uses, as described in the Entware wiki:
- Discovery: The firmware scans mounted USB partitions for a directory named
asusware.armat the partition root (suffix depends on architecture;asusware.armon this aarch64 router). It exposes that directory as/opt— this is why/optexists even without Entware. During detection the partition is unmounted and re-mounted, so anything mounted earlier from it is gone; do your own mounting inside the init script. - Init scripts: At boot/mount the firmware runs
/usr/sbin/app_init_run.sh allpkg start, which iterates over/opt/etc/init.d/S*and runs each script with the argumentstart(on unmount withstop). TheS<nn>prefix controls ordering (S99...runs last). - Enable gate: A script is skipped unless
/opt/lib/ipkg/info/<name>.controlcontains a lineEnabled: yes, where<name>is the script name without theS<nn>prefix. The field is read by/usr/sbin/app_get_field.shfrom the.controlfile. - Copy before run: Each script is first copied to
/opt/<Sname>.1and that copy is what actually gets executed (sh /opt/S99patch-and-restart-dnsmasq.1 start). So edits to the original only take effect after a remount/reboot. (On NTFS/fuseblkthe copy is instead sed-filtered to neuterchmod/chownlines.)
On this router the layout on the USB stick (/tmp/mnt/sda1) is:
/tmp/mnt/sda1/
├── asusware.arm/ # exposed as /opt
│ ├── .asusrouter # marker file, must exist (empty)
│ ├── etc/init.d/
│ │ └── S99patch-and-restart-dnsmasq # symlink -> ../../../data/patch-and-restart-dnsmasq.sh
│ └── lib/ipkg/info/
│ └── patch-and-restart-dnsmasq.control # "Enabled: yes" gates the start
└── data/
└── patch-and-restart-dnsmasq.sh # the real script (kept outside /opt)
The real script lives in data/ and is only symlinked into etc/init.d/, so it can be edited without touching the app directory. It expects start/stop as $1, logs with logger -t <TAG> (check System Log for the tag after reboot), and in the start branch patches /etc/dnsmasq.conf to read conf-dir=/tmp/mnt/sda1/data/dnsmasq.d, opens the TFTP firewall ports and restarts dnsmasq.
The relevant files from the router (app_init_run.sh, app_get_field.sh, the init script, control file and the patch script) are kept as a mirror of the router filesystem under network/ax4200/router-files/.
Tips:
- Reboot and check the system log: look for the
asusware: ...detection lines, then your script's own log tag. - If the script doesn't run, make sure the
.controlfile hasEnabled: yes, the script name matches the control file name (minusS<nn>), and remember the.1copy semantics above. - Sometimes detection only works after installing Download Master once (on another stick), then swapping back.
nvram set stop_fsck=1skips the fsck delay at mount.