]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
Some minor improvements to the with-vdi script
authorZheng Li <dev@zheng.li>
Wed, 16 Jun 2010 15:26:42 +0000 (16:26 +0100)
committerZheng Li <dev@zheng.li>
Wed, 16 Jun 2010 15:26:42 +0000 (16:26 +0100)
- 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 <dev@zheng.li>
scripts/with-vdi

index a7cc03c764de0847523cdeab7e4de533038de6a9..7557487a4bfc57d7009f590096c02a00055f31fd 100755 (executable)
@@ -18,14 +18,17 @@ if [ -z "$(xe vdi-list params=uuid uuid=${VDI})" ]; then
   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 @@ DEVICE=`xe vbd-param-get uuid=${VBD} param-name=device`
 export DEVICE
 echo DEVICE=${DEVICE}
 ${COMMAND}
+RC=$?
 xe vbd-unplug uuid=${VBD}
 xe vbd-destroy uuid=${VBD}
-
+exit ${RC}