NetVM: agent-friendly exec primitive (local + fleet)
This commit is contained in:
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/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 -q "^warp-${NODE}" || { 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" -- "$@"
|
||||
Reference in New Issue
Block a user