mirror of
https://github.com/Qortal/Brooklyn.git
synced 2025-01-31 07:12:18 +00:00
24 lines
323 B
Bash
24 lines
323 B
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Execute a subprocess in a network namespace
|
|
|
|
set -e
|
|
|
|
readonly NETNS="ns-$(mktemp -u XXXXXX)"
|
|
|
|
setup() {
|
|
ip netns add "${NETNS}"
|
|
ip -netns "${NETNS}" link set lo up
|
|
}
|
|
|
|
cleanup() {
|
|
ip netns del "${NETNS}"
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
setup
|
|
|
|
ip netns exec "${NETNS}" "$@"
|
|
exit "$?"
|