+log_error() {
+ echo "$@" >&2
+}
+
SCRIPT_NAME=$(basename $0)
for dir in /lib/udev /sbin; do
done
if [ -z "$VOL_ID" ]; then
- echo "vol_id not found, please install udev"
+ log_error "vol_id not found, please install udev"
exit 1
fi
get_api5_arguments() {
TEMP=`getopt -o o:n:i:b:s: -n '$0' -- "$@"`
- if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
+ if [ $? != 0 ] ; then log_error "Terminating..."; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true; do
--) shift; break;;
- *) echo "Internal error!"; exit 1;;
+ *) log_error "Internal error!" >&2; exit 1;;
esac
done
if [ -z "$instance" -o -z "$blockdev" ]; then
- echo "Missing OS API Argument"
+ log_error "Missing OS API Argument (-i, -n, or -b)"
exit 1
fi
if [ "$SCRIPT_NAME" != "export" -a -z "$swapdev" ]; then
- echo "Missing OS API Argument"
+ log_error "Missing OS API Argument -s (swapdev)"
exit 1
fi
- if [ "$SCRIPT_NAME" = "rename" -a -z "$new_name" ]; then
- echo "Missing OS API Argument"
+ if [ "$SCRIPT_NAME" = "rename" -a -z "$old_name" ]; then
+ log_error "Missing OS API Argument -o (old_name)"
exit 1
fi
}
get_api10_arguments() {
if [ -z "$INSTANCE_NAME" -o -z "$HYPERVISOR" -o -z "$DISK_COUNT" ]; then
- echo "Missing OS API Variable"
+ log_error "Missing OS API Variable:"
+ log_error "(INSTANCE_NAME HYPERVISOR or DISK_COUNT)"
exit 1
fi
instance=$INSTANCE_NAME
if [ $DISK_COUNT -lt 1 -o -z "$DISK_0_PATH" ]; then
- echo "At least one disk is needed"
+ log_error "At least one disk is needed"
exit 1
fi
blockdev=$DISK_0_PATH
if [ "$SCRIPT_NAME" = "rename" -a -z "$OLD_INSTANCE_NAME" ]; then
- echo "Missing OS API Variable"
+ log_error "Missing OS API Variable OLD_INSTANCE_NAME"
fi
old_name=$OLD_INSTANCE_NAME
}
elif [ "$OS_API_VERSION" = "10" ]; then
get_api10_arguments
if [ $SCRIPT_NAME = "import" -o $SCRIPT_NAME = "export" ]; then
- echo "import/export still not compatible with API version 10"
+ log_error "import/export still not compatible with API version 10"
exit 1
fi
else
- echo "Unknown OS API VERSION $OS_API_VERSION"
+ log_error "Unknown OS API VERSION $OS_API_VERSION"
exit 1
fi