interplane.Get Omega
Read in your language

omnet

aien-dev/omnet

Brought by drakestapleton

branch main Branches Tags History

omnet / integration / e2e / run.sh

41 lines · 2416 bytes Raw Blame History
1#!/bin/sh
2# Test-only. Prerequisites (acquisition/build may use the network):
3# GO=/path/to/go GOTOOLCHAIN=auto sh integration/e2e/build-clients.sh
4# GO=/path/to/go GOTOOLCHAIN=auto sh integration/headscale/build.sh
5# sh tools/build-tkad.sh
6# Then, on Linux with unprivileged user/network namespaces enabled:
7# sh integration/e2e/run.sh [--keep] [--result /absolute/result.json]
8# If user namespaces are prohibited, explicitly opt into namespace setup only:
9# sh integration/e2e/run.sh --sudo-netns [--keep] [--result /absolute/result.json]
10# This uses sudo -n, creates a NEW network namespace with loopback and a dummy
11# link (no egress), then drops all UID/GID privileges to the invoking user before
12# creating state or launching any daemon. No implicit sudo or host-network fallback.
13# Requires python3, util-linux unshare, iproute2 ip. Never uses the host tailnet,
14# Docker, a host network interface, or a global tailscaled socket.
15# --keep retains private temporary logs/state (including disposable private keys).
16# Default cleanup removes only the directory created by this invocation.
17# Runbook rehearsal (docs/runbook.md), which also needs an unpatched server:
18# HEADSCALE_STOCK=1 HEADSCALE_OUTPUT=build/headscale-stock GO=... sh integration/headscale/build.sh
19# sh integration/e2e/run.sh --sudo-netns --scenario runbook --stock-headscale build/headscale-stock
20set -eu
21ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
22for tool in unshare ip python3; do
23 command -v "$tool" >/dev/null || { printf 'NOT_RUN: required tool %s unavailable\n' "$tool" >&2; exit 77; }
24done
25OUTER=$(readlink /proc/self/ns/net)
26BIN=${E2E_BIN_DIR:-"$ROOT/build/e2e"}
27HS=${HEADSCALE_BIN:-"$ROOT/build/headscale"}
28TKAD=${TKAD_BIN:-"$ROOT/build/tkad"}
29if [ "${1:-}" = "--sudo-netns" ]; then
30 shift
31 UID_NOW=$(id -u)
32 GID_NOW=$(id -g)
33 [ "$UID_NOW" -ne 0 ] || { printf 'NOT_RUN: invoke --sudo-netns as the ordinary test user\n' >&2; exit 77; }
34 exec sudo -n unshare --net --pid --fork --kill-child \
35 python3 "$ROOT/integration/e2e/lifecycle.py" --outer-netns "$OUTER" \
36 --run-uid "$UID_NOW" --run-gid "$GID_NOW" \
37 --bin-dir "$BIN" --headscale "$HS" --tkad "$TKAD" "$@"
38fi
39exec unshare --user --map-root-user --net --pid --fork --kill-child \
40 python3 "$ROOT/integration/e2e/lifecycle.py" --outer-netns "$OUTER" \
41 --bin-dir "$BIN" --headscale "$HS" --tkad "$TKAD" "$@"