345eb09559
echo "$list" | grep -q under set -o pipefail exits 141 whenever grep matches before echo finishes writing, so healthy browsers were reported 'CDP up but no page target' and killed every 2 min fleet-wide (load 19+). Use [[ == *glob* ]] (no pipe, no race) for the page/muse.ai stages, and grep -c (reads to EOF, never early-exits) for the netns check.
14 lines
884 B
Bash
Executable File
14 lines
884 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# netvm-exec.sh <node> -- <cmd> [args...] — run a command inside the node's
|
|
# netns as the invoking user. The agent-friendly primitive for "do X in the
|
|
# node's network": egress tests, automation, debugging.
|
|
# (The node must be up; see netvm-node-up.sh / netvm-fleet.sh up.)
|
|
set -euo pipefail
|
|
NETVM_BIN="$(cd "$(dirname "$0")" && pwd)"
|
|
NODE="${1:?usage: netvm-exec.sh <node> -- <cmd> [args...]}"; shift
|
|
[ "${1:-}" = "--" ] && shift
|
|
[ $# -gt 0 ] || { echo "usage: netvm-exec.sh <node> -- <cmd> [args...]"; exit 1; }
|
|
[ -f "/etc/netvm/${NODE}.conf" ] || { echo "no warp identity for '$NODE' (human: netvm-new-identity.sh $NODE)"; exit 1; }
|
|
[ "$(ip netns list 2>/dev/null | grep -c "^warp-${NODE}")" -ge 1 ] || { echo "node '$NODE' is not up (netvm-node-up.sh $NODE)"; exit 1; }
|
|
exec sudo -n "$NETVM_BIN/netvm-enter.sh" "$NODE" "$(id -u)" "$(id -g)" "$HOME" -- "$@"
|