Fix the help output for tripleo-mount-image
This change does the following to fix the help output of tripleo-mount-image and tripleo-unmount-image - defer set -x until actual inside the actual mount/unmount functions - add --help to the getopt long arguments so it actually works - print help and exit if mandatory arguments -a, -m are missing Blueprint: whole-disk-default Change-Id: I6d16fd95c098559af9ec4e38b336819fc1663eef
This commit is contained in:
parent
369b24bcf0
commit
6579b6858c
|
@ -19,10 +19,11 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
set -x
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
SCRIPT_NAME=$(basename $0)
|
SCRIPT_NAME=$(basename $0)
|
||||||
NBD_DEVICE=/dev/nbd0
|
NBD_DEVICE=/dev/nbd0
|
||||||
|
IMAGE_FILE=""
|
||||||
|
MOUNT_DIR=""
|
||||||
if [ ! -a "${NBD_DEVICE}" ]; then
|
if [ ! -a "${NBD_DEVICE}" ]; then
|
||||||
modprobe nbd
|
modprobe nbd
|
||||||
fi
|
fi
|
||||||
|
@ -167,7 +168,7 @@ unmount_image() {
|
||||||
|
|
||||||
|
|
||||||
if [ $SCRIPT_NAME == "tripleo-unmount-image" ]; then
|
if [ $SCRIPT_NAME == "tripleo-unmount-image" ]; then
|
||||||
TEMP=`getopt -o hm:n: -n $SCRIPT_NAME -- "$@"`
|
TEMP=`getopt -o hm:n: -l help -n $SCRIPT_NAME -- "$@"`
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Terminating..." >&2
|
echo "Terminating..." >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -183,9 +184,12 @@ if [ $SCRIPT_NAME == "tripleo-unmount-image" ]; then
|
||||||
*) echo "Error: unsupported option $1." ; exit 1;;
|
*) echo "Error: unsupported option $1." ; exit 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
if [ -z "${MOUNT_DIR}" ]; then
|
||||||
|
unmount_show_options 1
|
||||||
|
fi
|
||||||
unmount_image
|
unmount_image
|
||||||
else
|
else
|
||||||
TEMP=`getopt -o ha:m:n: -n $SCRIPT_NAME -- "$@"`
|
TEMP=`getopt -o ha:m:n: -l help -n $SCRIPT_NAME -- "$@"`
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Terminating..." >&2
|
echo "Terminating..." >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -203,5 +207,8 @@ else
|
||||||
*) echo "Error: unsupported option $1." ; exit 1;;
|
*) echo "Error: unsupported option $1." ; exit 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
if [ -z "${MOUNT_DIR}" ] || [ -z "${IMAGE_FILE}"]; then
|
||||||
|
mount_show_options 1
|
||||||
|
fi
|
||||||
mount_image
|
mount_image
|
||||||
fi
|
fi
|
Loading…
Reference in New Issue