File: priv-net-run.sh

package info (click to toggle)
golang-github-appc-cni 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,132 kB
  • sloc: sh: 154; makefile: 7
file content (20 lines) | stat: -rwxr-xr-x 434 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
set -e
if [[ ${DEBUG} -gt 0 ]]; then set -x; fi

# Run a command in a private network namespace
# set up by CNI plugins
contid=$(printf '%x%x%x%x' $RANDOM $RANDOM $RANDOM $RANDOM)
netnspath=/var/run/netns/$contid

ip netns add $contid
./exec-plugins.sh add $contid $netnspath


function cleanup() {
	./exec-plugins.sh del $contid $netnspath
	ip netns delete $contid
}
trap cleanup EXIT

ip netns exec $contid "$@"