From 644aaf817e080fb1c568911495481763ed9c6a47 Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Mon, 22 Apr 2019 20:39:31 +0200 Subject: [PATCH] * Added option to pass optional arguments to command executed in namespace. * Disabled set -x. --- nns.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nns.sh b/nns.sh index 7fa81ad..b1eb2b1 100755 --- a/nns.sh +++ b/nns.sh @@ -47,6 +47,7 @@ NAMESRV="8.8.8.8 8.8.4.4" # Program to run in the new network namespace: XCMD1=xterm +XCMD1_ARGS= # Virtual Ethernet to connect new network namespace to default namespace: VETH_HOST=veth_host @@ -56,7 +57,7 @@ VETH_GUEST=veth_guest ############################### -set -x +#set -x SHORTNAME=${0##*/} @@ -100,10 +101,11 @@ if [ -z $DHCLIENT ] ; then exit 1 fi +# Locate user provided command: if [ -n "XCMD1" ] ; then XCMD=$(command -v $XCMD1) if [ -z $XCMD ] ; then - echo "please install the $XCMD1 package" + echo "command not found: $XCMD1" exit 1 fi fi @@ -172,7 +174,7 @@ start_nns() { # Run the configured command, if any, inside the namespace: if [ -n "$XCMD" ] ; then - $IP netns exec $1 su -p -c "$XCMD" $SUDO_USER & + $IP netns exec $1 su -p -c "$XCMD $XCMD1_ARGS" $SUDO_USER & $IP netns exec $1 echo "$!" > "$RUNDIR/xcmd_.pid" fi } -- 2.30.2