+mns() { # mount namespace
+ ns=$1
+ shift
+ s mkdir -p /root/mount_namespaces
+ if ! sudo mountpoint /root/mount_namespaces >/dev/null; then
+ m sudo mount --bind /root/mount_namespaces /root/mount_namespaces
+ fi
+ m sudo mount --make-private /root/mount_namespaces
+ if [[ ! -e /root/mount_namespaces/$ns ]]; then
+ m sudo touch /root/mount_namespaces/$ns
+ fi
+ if ! sudo mountpoint /root/mount_namespaces/$ns >/dev/null; then
+ m sudo unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true
+ fi
+ m sudo -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@"
+}
+
+mnsr() { # mns run
+ local ns=$1
+ shift
+ mns $ns sudo -u iank -E env "PATH=$PATH" "$@"
+}
+
+mnsnonet() {
+ ns=$1
+ if ! s ip netns list | grep -Fx nonet &>/dev/null; then
+ s ip netns add nonet
+ fi
+ mns $ns --net=/var/run/netns/nonet sudo -E -u iank /bin/bash
+ lomh
+}
+
+