diff --git a/virt-install-cloud.sh b/virt-install-cloud.sh index 881af86..e8e0f25 100755 --- a/virt-install-cloud.sh +++ b/virt-install-cloud.sh @@ -24,20 +24,6 @@ if [[ $USER != "root" ]]; then echo "This script must be run as root!" && exit 1 fi -while getopts "hcr:s:n:d:iob" opt; do - case $opt in - c) cpucount=("$OPTARG");; - r) ram=("$OPTARG");; - s) storage=("$OPTARG");; - n) hostname=("$OPTARG");; - d) domain=("$OPTARG");; - i) distro=("$OPTARG");; - o) ostype=("$OPTARG");; - b) bridge=("$OPTARG");; - h) usage;; - esac -done - usage() { echo "${0} Help" echo "-h show this help" @@ -51,7 +37,22 @@ usage() { echo "-o OS type and variant (default: generic:generic - also set by distro option when available)" } -if [[ -z $ram || -z $storage || -z $hostname || -z $domain || -z $bridge ]]; then +while getopts "hcr:s:n:d:iob" opt; do + case $opt in + c) cpucount=("$OPTARG");; + r) ram=("$OPTARG");; + s) storage=("$OPTARG");; + n) hostname=("$OPTARG");; + d) domain=("$OPTARG");; + i) distro=("$OPTARG");; + o) ostype=("$OPTARG");; + b) bridge=("$OPTARG");; + h) help="yes";; + esac +done + + +if [[ -z $ram || -z $storage || -z $hostname || -z $domain || -z $bridge || $help = "yes" ]]; then echo "Error: Incorrect command usage, must provide all * flags." usage exit 1