setup wizard: fix routing, DHCP, WiFi AP, firewall, and deploy task

Setup script fixes:
- _cidr_to_mask: pad to 4 octets (/24 -> 255.255.255.0)
- UCI quoting: remove embedded shell quotes from uci set calls
- Bridge ports: auto-detect zt* interface instead of hardcoding ztabc0
- Bridge netmask: default to /23 (255.255.254.0) for ZT+WIBLAN
- DHCP/WiFi AP: reference interface name (zt_wiblan) not device name (br_zt)
- Firewall zone: add zt_wiblan to LAN zone for nftables fw4
- ZT IP persistence: ensure ZT-assigned IP stays on interface for ARP
- Exit gateway routing: table 100/101 route via exit gateway, not self
- New setup-wifi-ap subcommand for WIBLAN WiFi AP

UBUS handler:
- Add setup-wifi-ap to validation regex and error message

Deploy task:
- Auto-discover files from root/ and htdocs/ instead of hardcoded list
- Clear LuCI cache before restarting services

Documentation:
- New docs/SETUP-GATEWAY.md with architecture, config, pitfalls, checklist
- Updated docs/INSTALL.md with deploy task and setup wizard sections
- Updated docs/PROGRESS.md with session log and learnings
This commit is contained in:
2026-07-13 11:10:57 +05:30
parent cd429291ef
commit 1e4a46c4bf
11 changed files with 1045 additions and 81 deletions

View File

@@ -42,36 +42,32 @@ opkg install luci-base luci-compat ucode rpcd-mod-ucode luci-theme-bootstrap
The fastest way during development. No build step required.
```bash
HOST=root@192.168.15.1
# Upload files
scp root/usr/sbin/zt-gateway-switch $HOST:/usr/sbin/
scp root/usr/share/rpcd/ucode/zt-gateway.uc $HOST:/usr/share/rpcd/ucode/
scp root/usr/share/rpcd/ucode/system.uc $HOST:/usr/share/rpcd/ucode/
scp root/usr/share/ucode/luci/runtime.uc $HOST:/usr/share/ucode/luci/
scp root/usr/share/luci/menu.d/luci-app-zt-gateway.json $HOST:/usr/share/luci/menu.d/
scp root/usr/share/rpcd/acl.d/luci-app-zt-gateway.json $HOST:/usr/share/rpcd/acl.d/
scp root/etc/config/zt-gateway $HOST:/etc/config/
scp htdocs/luci-static/resources/view/zt-gateway/overview.js $HOST:/www/luci-static/resources/view/zt-gateway/
# Set permissions and restart services
ssh $HOST 'chmod +x /usr/sbin/zt-gateway-switch; /etc/init.d/rpcd restart; /etc/init.d/uhttpd restart'
```
Or use the mise task (same thing, one command):
```bash
mise run deploy:install
# or with a custom target:
HOST=root@10.0.0.1 mise run deploy:install
```
The deploy task auto-discovers all files from `root/` and `htdocs/`,
maps them to device paths, and restarts services. New files are
automatically included without editing the task.
Open `http://<device-ip>/cgi-bin/luci/admin/services/zt-gateway`.
**Note:** This method has no dependency tracking. The package manager won't know
about the installed files. Use for dev only.
### Setting up as Exit Gateway
After deploying, run the setup wizard from the LuCI UI (Setup panel)
or CLI:
```bash
ssh root@<device-ip> '/usr/sbin/zt-gateway-setup setup-all'
```
See [SETUP-GATEWAY.md](SETUP-GATEWAY.md) for detailed configuration
and troubleshooting.
---
## Method 2: Local Package Install via SCP
@@ -221,6 +217,7 @@ These are the files installed by this package and their target locations:
| Source | Target | Purpose |
|---|---|---|
| `root/usr/sbin/zt-gateway-setup` | `/usr/sbin/zt-gateway-setup` | Gateway setup script |
| `root/usr/sbin/zt-gateway-switch` | `/usr/sbin/zt-gateway-switch` | Gateway switching script |
| `root/usr/share/rpcd/ucode/zt-gateway.uc` | `/usr/share/rpcd/ucode/zt-gateway.uc` | rpcd backend |
| `root/usr/share/rpcd/ucode/system.uc` | `/usr/share/rpcd/ucode/system.uc` | system.board rpcd override |