Browse Source

Avoid deleting directory when not specifying a hostname to create/remove.

- Exit when none or two or more hostnames are specified.
- Accept help as a subcommand for create and remove.
pull/6/head
Giovanni Torres 8 years ago
parent
commit
a3477c44ff
  1. 26
      kvm-install-vm

26
kvm-install-vm

@ -33,11 +33,14 @@ function usage_subcommand ()
create)
cat << EOF
NAME
$prog create [OPTIONS] VMNAME
$prog create [COMMANDS] [OPTIONS] VMNAME
DESCRIPTION
Create a new guest domain.
COMMANDS
help - show this help
OPTIONS
-b Bridge (default: virbr0)
-c Number of vCPUs (default: 1)
@ -83,12 +86,15 @@ EOF
remove)
cat << EOF
NAME
$prog remove VMNAME
$prog remove [COMMANDS] VMNAME
DESCRIPTION
Destroys (stops) and undefines a guest domain. This also remove the
associated storage pool.
COMMANDS
help - show this help
EXAMPLE
$prog remove foo
Remove (destroy and undefine) a guest domain. WARNING: This will
@ -520,7 +526,9 @@ function create ()
if [ "$#" != 1 ]
then
printf "Too many options.\n"
printf "Please specify a single host to create.\n"
printf "Run 'kvm-install-vm help create' for usage.\n"
exit 1
else
VMNAME=$1
fi
@ -595,8 +603,16 @@ case "${subcommand}" in
exit 0
;;
create|remove)
"${subcommand}" "$@"
exit $?
if [[ "${1:-none}" == "none" ]]; then
usage_subcommand "${subcommand}"
exit 1
elif [[ "$1" =~ ^help$ ]]; then
usage_subcommand "${subcommand}"
exit 1
else
"${subcommand}" "$@"
exit $?
fi
;;
*)
echo "not valid"

Loading…
Cancel
Save