* Added option to pass optional arguments to command executed in namespace.
authorUrban Wallasch <urban.wallasch@freenet.de>
Mon, 22 Apr 2019 18:39:31 +0000 (20:39 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Mon, 22 Apr 2019 18:39:31 +0000 (20:39 +0200)
* Disabled set -x.

nns.sh

diff --git a/nns.sh b/nns.sh
index 7fa81ade0d7310415ba47e1ce37470d2c8d11741..b1eb2b1c96513ce5a7b49406ce5debfc4676f444 100755 (executable)
--- 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
 }