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

@@ -87,32 +87,28 @@ echo " ${HOST} is reachable."
echo "==> Uploading files..."
# root/ files → strip leading root/, map to / on device
scp -O -q root/usr/sbin/zt-gateway-switch "$HOST:/usr/sbin/"
scp -O -q root/usr/sbin/zt-gateway-setup "$HOST:/usr/sbin/"
echo " zt-gateway-setup"
echo " zt-gateway-switch"
scp -O -q root/usr/share/rpcd/ucode/zt-gateway.uc "$HOST:/usr/share/rpcd/ucode/"
echo " rpcd/ucode/zt-gateway.uc"
scp -O -q root/usr/share/rpcd/ucode/system.uc "$HOST:/usr/share/rpcd/ucode/"
echo " rpcd/ucode/system.uc"
scp -O -q root/usr/share/ucode/luci/runtime.uc "$HOST:/usr/share/ucode/luci/"
echo " ucode/luci/runtime.uc"
scp -O -q root/usr/share/luci/menu.d/luci-app-zt-gateway.json "$HOST:/usr/share/luci/menu.d/"
echo " menu.d/luci-app-zt-gateway.json"
scp -O -q root/usr/share/rpcd/acl.d/luci-app-zt-gateway.json "$HOST:/usr/share/rpcd/acl.d/"
echo " acl.d/luci-app-zt-gateway.json"
scp -O -q root/etc/config/zt-gateway "$HOST:/etc/config/"
echo " config/zt-gateway"
# Frontend view
ssh -q "$HOST" mkdir -p /www/luci-static/resources/view/zt-gateway
scp -O -q htdocs/luci-static/resources/view/zt-gateway/overview.js "$HOST:/www/luci-static/resources/view/zt-gateway/"
echo " overview.js"
# Auto-discover files from root/ and htdocs/, map to device paths.
# root/usr/sbin/foo → /usr/sbin/foo
# htdocs/luci-static/... /www/luci-static/...
UPLOADED=0
find root/ htdocs/ -type f | sort | while IFS= read -r src; do
case "$src" in
root/*) dest="/${src#root/}" ;;
htdocs/*) dest="/www/${src#htdocs/}" ;;
*) echo "SKIP: $src (unknown prefix)"; continue ;;
esac
destdir="${dest%/*}"
ssh -q "$HOST" mkdir -p "$destdir"
scp -O -q "$src" "$HOST:$dest"
echo " ${src#./}"
UPLOADED=$((UPLOADED + 1))
done
echo "==> Setting permissions..."
ssh -q "$HOST" chmod +x /usr/sbin/zt-gateway-switch /usr/sbin/zt-gateway-setup
echo "==> Restarting rpcd and uhttpd..."
ssh -q "$HOST" find /usr/sbin -name 'zt-gateway-*' -exec chmod +x {} +
echo "==> Clearing LuCI cache and restarting services..."
ssh -q "$HOST" rm -rf /tmp/luci-* 2>/dev/null || true
ssh -q "$HOST" /etc/init.d/rpcd restart
ssh -q "$HOST" /etc/init.d/uhttpd restart