aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeel Natu <neel@FreeBSD.org>2015-01-18 01:50:10 +0000
committerNeel Natu <neel@FreeBSD.org>2015-01-18 01:50:10 +0000
commit1bd468a4e9f24b938580c09cbb3b24010f07bb29 (patch)
tree12e3ff856a87c3faacae6151fcf8462964980395
parenta9c42ce4b9fcb5901dca6306ce6a99ab43ad3811 (diff)
downloadsrc-1bd468a4e9f24b938580c09cbb3b24010f07bb29.tar.gz
src-1bd468a4e9f24b938580c09cbb3b24010f07bb29.zip
Make the error message explicit instead of just printing the usage if the
virtual machine name is not specified. Requested by: grehan MFC after: 1 week
Notes
Notes: svn path=/head/; revision=277309
-rwxr-xr-xshare/examples/bhyve/vmrun.sh16
1 files changed, 11 insertions, 5 deletions
diff --git a/share/examples/bhyve/vmrun.sh b/share/examples/bhyve/vmrun.sh
index 93f3c94d9539..7a8007f07f74 100755
--- a/share/examples/bhyve/vmrun.sh
+++ b/share/examples/bhyve/vmrun.sh
@@ -39,7 +39,13 @@ DEFAULT_CONSOLE=stdio
DEFAULT_VIRTIO_DISK="./diskdev"
DEFAULT_ISOFILE="./release.iso"
+errmsg() {
+ echo "*** $1"
+}
+
usage() {
+ local msg=$1
+
echo "Usage: vmrun.sh [-ahi] [-c <CPUs>] [-C <console>] [-d <disk file>]"
echo " [-e <name=value>] [-g <gdbport> ] [-H <directory>]"
echo " [-I <location of installation iso>] [-m <memsize>]"
@@ -58,18 +64,18 @@ usage() {
echo " -m: memory size (default is ${DEFAULT_MEMSIZE})"
echo " -t: tap device for virtio-net (default is $DEFAULT_TAPDEV)"
echo ""
- echo " This script needs to be executed with superuser privileges"
- echo ""
+ [ -n "$msg" ] && errmsg "$msg"
exit 1
}
if [ `id -u` -ne 0 ]; then
- usage
+ errmsg "This script must be executed with superuser privileges"
+ exit 1
fi
kldstat -n vmm > /dev/null 2>&1
if [ $? -ne 0 ]; then
- echo "vmm.ko is not loaded!"
+ errmsg "vmm.ko is not loaded"
exit 1
fi
@@ -140,7 +146,7 @@ fi
shift $((${OPTIND} - 1))
if [ $# -ne 1 ]; then
- usage
+ usage "virtual machine name not specified"
fi
vmname="$1"