- return the user command's exit code as the exit code of with-vdi script 
(unless something else failed in the preparation or post run steps)
- relax the requirement on the user command parameter, both absolute paths and 
in-paths executables are acceptable
- allow a user command to have its own arguments (i.e. with-vdi vdi-uuid 
user-command arg1 arg2 ... argn)

Signed-off-by: Zheng Li <[email protected]>


 scripts/with-vdi |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)


diff -r c0e27f018867 -r a6596df3debe scripts/with-vdi
--- a/scripts/with-vdi  Tue May 04 07:18:23 2010 +0100
+++ b/scripts/with-vdi  Wed Jun 16 16:26:42 2010 +0100
@@ -18,14 +18,17 @@
   usage
   exit 1
 fi
+
 COMMAND=$2
 if [ -z "$COMMAND" ]; then
   COMMAND=/bin/sh
-fi
-if [ ! -x "$COMMAND" ]; then
+elif ! which "$COMMAND" > /dev/null ; then
   echo Failed to find command: ${COMMAND}
   usage
   exit 1
+else
+  shift 1
+  COMMAND=$*
 fi
 
 . /etc/xensource-inventory
@@ -41,6 +44,7 @@
 export DEVICE
 echo DEVICE=${DEVICE}
 ${COMMAND}
+RC=$?
 xe vbd-unplug uuid=${VBD}
 xe vbd-destroy uuid=${VBD}
-
+exit ${RC}
# HG changeset patch
# User Zheng Li <[email protected]>
# Date 1276702002 -3600
# Node ID a6596df3debeb89ae79920b08144154f6752b86a
# Parent  c0e27f0188678152aee18030e1786be9dab9806e
Some minor improvements to the with-vdi script

- return the user command's exit code as the exit code of with-vdi script (unless something else failed in the preparation or post run steps)
- relax the requirement on the user command parameter, both absolute paths and in-paths executables are acceptable
- allow a user command to have its own arguments (i.e. with-vdi vdi-uuid user-command arg1 arg2 ... argn)

Signed-off-by: Zheng Li <[email protected]>

diff -r c0e27f018867 -r a6596df3debe scripts/with-vdi
--- a/scripts/with-vdi	Tue May 04 07:18:23 2010 +0100
+++ b/scripts/with-vdi	Wed Jun 16 16:26:42 2010 +0100
@@ -18,14 +18,17 @@
   usage
   exit 1
 fi
+
 COMMAND=$2
 if [ -z "$COMMAND" ]; then
   COMMAND=/bin/sh
-fi
-if [ ! -x "$COMMAND" ]; then
+elif ! which "$COMMAND" > /dev/null ; then
   echo Failed to find command: ${COMMAND}
   usage
   exit 1
+else
+  shift 1
+  COMMAND=$*
 fi
 
 . /etc/xensource-inventory
@@ -41,6 +44,7 @@
 export DEVICE
 echo DEVICE=${DEVICE}
 ${COMMAND}
+RC=$?
 xe vbd-unplug uuid=${VBD}
 xe vbd-destroy uuid=${VBD}
-
+exit ${RC}
_______________________________________________
xen-api mailing list
[email protected]
http://lists.xensource.com/mailman/listinfo/xen-api

Reply via email to