Move usage function up to avoid issues, adjust help option

master
Brie Bruns 6 years ago
parent 5fc9a39bff
commit f7e75308ce

@ -24,6 +24,19 @@ if [[ $USER != "root" ]]; then
echo "This script must be run as root!" && exit 1
fi
usage() {
echo "${0} Help"
echo "-h show this help"
echo "-n hostname *"
echo "-d domainame *"
echo "-s disk size (num + count size - M=Megabytes G=Gigabytes) *"
echo "-r ram size (in kilobytes) *"
echo "-c number of vcpus"
echo "-b bridge to attach to *"
echo "-i distribution to use (see script for supported options) - default is stretch"
echo "-o OS type and variant (default: generic:generic - also set by distro option when available)"
}
while getopts "hcr:s:n:d:iob" opt; do
case $opt in
c) cpucount=("$OPTARG");;
@ -34,24 +47,12 @@ while getopts "hcr:s:n:d:iob" opt; do
i) distro=("$OPTARG");;
o) ostype=("$OPTARG");;
b) bridge=("$OPTARG");;
h) usage;;
h) help="yes";;
esac
done
usage() {
echo "${0} Help"
echo "-h show this help"
echo "-n hostname *"
echo "-d domainame *"
echo "-s disk size (num + count size - M=Megabytes G=Gigabytes) *"
echo "-r ram size (in kilobytes) *"
echo "-c number of vcpus"
echo "-b bridge to attach to *"
echo "-i distribution to use (see script for supported options) - default is stretch"
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
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

Loading…
Cancel
Save