- 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>
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
export DEVICE
echo DEVICE=${DEVICE}
${COMMAND}
+RC=$?
xe vbd-unplug uuid=${VBD}
xe vbd-destroy uuid=${VBD}
-
+exit ${RC}