sync: auto-sync from HOWARD-HOME at 2026-06-15 21:59:42
Author: Howard Enos Machine: HOWARD-HOME Timestamp: 2026-06-15 21:59:42
This commit is contained in:
@@ -6,7 +6,10 @@
|
||||
#
|
||||
# REQUIRES: L3 reach to the AP's mgmt IP. At Cascades the APs are on 192.168.2.x/3.x (mgmt VLANs) —
|
||||
# bring up the Cascades VPN first. Device-auth SSH cred is vaulted (clients/cascades-tucson/unifi-ap-ssh).
|
||||
# Needs `sshpass` locally (UniFi device-auth is password-based). Find AP IPs via:
|
||||
# AUTH (UniFi device-auth is password-based): uses `sshpass` if installed, otherwise falls back to
|
||||
# OpenSSH's SSH_ASKPASS helper (no sshpass needed). NOTE the fallback uses `ssh` from PATH: on Windows
|
||||
# that must be MSYS/Git-bash ssh — Win10/11 system OpenSSH cannot exec a shell askpass (CreateProcessW
|
||||
# error 193); on Linux/macOS system ssh works fine. Find AP IPs via:
|
||||
# echo 'db.device.find({site_id:"685f39068e65331c46ef6dd2",type:"uap"},{name:1,ip:1}).forEach(printjson)' | bash .claude/scripts/uos-mongo.sh
|
||||
#
|
||||
# Usage: bash .claude/skills/unifi-wifi/scripts/watch-ap.sh <ap-ip> [interval=2] [vault-path]
|
||||
@@ -17,12 +20,23 @@ AP="${1:?usage: watch-ap.sh <ap-ip> [interval] [vault-path]}"; INT="${2:-2}"; VP
|
||||
U="$(bash "$VAULT" get-field "$VP" credentials.username 2>/dev/null)"
|
||||
P="$(bash "$VAULT" get-field "$VP" credentials.password 2>/dev/null)"
|
||||
[ -n "$U" ] && [ -n "$P" ] || { echo "[ERROR] no device-auth cred at vault:$VP"; exit 1; }
|
||||
command -v sshpass >/dev/null || { echo "[ERROR] sshpass not installed (apt-get install sshpass / brew install sshpass)"; exit 1; }
|
||||
|
||||
# Auth method: sshpass if available, else SSH_ASKPASS fallback (no sshpass needed).
|
||||
SSH_OPTS=(-o ConnectTimeout=8 -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null \
|
||||
-o PreferredAuthentications=password -o PubkeyAuthentication=no -o NumberOfPasswordPrompts=1)
|
||||
if command -v sshpass >/dev/null 2>&1; then
|
||||
run_ssh() { SSHPASS="$P" sshpass -e ssh "${SSH_OPTS[@]}" "$@"; }
|
||||
echo "[INFO] auth: sshpass"
|
||||
else
|
||||
ASKPASS="$(mktemp)"; printf '#!/bin/sh\nprintf "%%s\\n" "$WATCH_AP_PW"\n' > "$ASKPASS"; chmod +x "$ASKPASS"
|
||||
trap 'rm -f "$ASKPASS"' EXIT
|
||||
run_ssh() { WATCH_AP_PW="$P" SSH_ASKPASS="$ASKPASS" SSH_ASKPASS_REQUIRE=force DISPLAY="${DISPLAY:-:0}" ssh "${SSH_OPTS[@]}" "$@"; }
|
||||
echo "[INFO] auth: SSH_ASKPASS fallback (sshpass not installed)"
|
||||
fi
|
||||
|
||||
echo "[INFO] watching $AP every ${INT}s (Ctrl-C to stop). Needs Cascades VPN reach."
|
||||
# Run the sampling loop ON the AP so each tick is one round-trip; mca-dump for cu/clients, iw survey for busy%/noise.
|
||||
SSHPASS="$P" sshpass -e ssh -o ConnectTimeout=8 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||
"$U@$AP" "INT=$INT sh -s" <<'REMOTE' 2>&1 | grep -viE 'Warning: Permanently|pq.html'
|
||||
run_ssh "$U@$AP" "INT=$INT sh -s" <<'REMOTE' 2>&1 | grep -viE 'Warning: Permanently|pq.html'
|
||||
radios=$(iw dev 2>/dev/null | awk '/Interface/{print $2}' | grep -E 'wifi|ath' || echo "wifi0 wifi1 wifi2")
|
||||
prev=""
|
||||
while :; do
|
||||
|
||||
Reference in New Issue
Block a user