network:ax4200:install_additional_software

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
network:ax4200:install_additional_software [2023/08/09 17:03] – created adminnetwork:ax4200:install_additional_software [2026/10/25 17:49] (current) – admin
Line 3: Line 3:
 You can get a system for installing additional software by: You can get a system for installing additional software by:
  
-1. plugging in a partitioned, ext4 formatted USB device+1. plugging in a partitioned, ext4 formatted USB device  
 2. enabling `Download Master` on that USB device 2. enabling `Download Master` on that USB device
  
Line 14: Line 14:
 wget -O - http://bin.entware.net/aarch64-k3.10/installer/generic.sh | sh 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) 
 + 
 +Using a non-standard `/opt/etc/init.d` startup script system, services can be launched on boot. 
 + 
 +We use the app mechanism that Download Master/Optware uses, as described in the [Entware wiki](https://github.com/Entware/Entware/wiki/Install-on-Asus-stock-firmware#alternative-asuswarearm-init-script-recent-firmware): 
 + 
 +1. **Discovery:** The firmware scans mounted USB partitions for a directory named `asusware.arm` at the partition root (suffix depends on architecture; `asusware.arm` on this aarch64 router). It exposes that directory as `/opt` — this is why `/opt` exists 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. 
 +2. **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 argument `start` (on unmount with `stop`). The `S<nn>` prefix controls ordering (`S99...` runs last). 
 +3. **Enable gate:** A script is skipped unless `/opt/lib/ipkg/info/<name>.control` contains a line `Enabled: yes`, where `<name>` is the script name without the `S<nn>` prefix. The field is read by `/usr/sbin/app_get_field.sh` from the `.control` file. 
 +4. **Copy before run:** Each script is first copied to `/opt/<Sname>.1` and 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/`fuseblk` the copy is instead sed-filtered to neuter `chmod`/`chown` lines.) 
 + 
 +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.  What this is used for is described in [Enable TFTP booting](Network:AX4200:Enable_TFTP_booting). 
 + 
 +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 `.control` file has `Enabled: yes`, the script name matches the control file name (minus `S<nn>`), and remember the `.1` copy semantics above. 
 +- Sometimes detection only works after installing Download Master once (on another stick), then swapping back. `nvram set stop_fsck=1` skips the fsck delay at mount.
network/ax4200/install_additional_software.1691593406.txt.gz · Last modified: by admin