#!/usr/bin/env bash # Preview install for the Link Health read-only plugin only. # Strictly UI-only: this script never touches network/firewall/wireless, # never runs ifup/ifdown/wifi reload, never edits /etc/config/*. # # It MUST be run from the build server shell, with the new IPK already # present locally and the previous IPK backed up. set -euo pipefail PKG_NAME="luci-app-tr3000-status" NEW_IPK="${1:?usage: install_preview.sh path/to/luci-app-tr3000-status__all.ipk}" ROUTER="${ROUTER:-root@192.168.1.2}" BACKUP_DIR="/root/.v46.1-preview/luci-app-tr3000-status" TIMESTAMP="$(date +%Y%m%d-%H%M%S)" [ -f "$NEW_IPK" ] || { echo "new ipk not found: $NEW_IPK" >&2; exit 2; } echo "[info] target router: $ROUTER" echo "[info] backup dir: $BACKUP_DIR/$TIMESTAMP" ssh -o BatchMode=yes "$ROUTER" "set -e; mkdir -p '$BACKUP_DIR/$TIMESTAMP'; if opkg list-installed | grep -q '$PKG_NAME'; then opkg list-installed $PKG_NAME | awk '{print \$3}' > '$BACKUP_DIR/$TIMESTAMP/prev_version'; fi; tar -C / -czf '$BACKUP_DIR/$TIMESTAMP/pre_overlay.tar.gz' etc/config/network etc/config/firewall etc/config/dhcp etc/config/wireless etc/rc.local etc/hotplug.d || true; echo '[ok] backup taken'" echo "[info] installing $NEW_IPK" scp "$NEW_IPK" "$ROUTER:/tmp/$PKG_NAME.ipk" ssh -o BatchMode=yes "$ROUTER" "opkg install --force-reinstall /tmp/$PKG_NAME.ipk && rm -f /tmp/$PKG_NAME.ipk && /etc/init.d/rpcd restart && /etc/init.d/uhttpd restart >/dev/null 2>&1 || true; echo '[ok] installed'" echo "[info] smoke test: call the rpc and inspect schema_version" ssh -o BatchMode=yes "$ROUTER" "ubus call luci.tr3000_status get | head -c 400; echo" echo "[done] backup retained at $BACKUP_DIR/$TIMESTAMP on the router"