From 31d78619092ba930f94f19599a677842ca66d216 Mon Sep 17 00:00:00 2001 From: Martin Kulhavy Date: Fri, 18 Aug 2017 17:43:49 +0300 Subject: Move help usage information to beginning of script If user requests the usage information (e.g. with `--help` argument), the information should be displayed right away. Currently the script first runs updates and installs of dependencies, which can take very long time. Change-Id: If5a75a98876ddeeb580764d823a11331ee8e9faf Signed-off-by: Martin Kulhavy --- ci/03-maasdeploy.sh | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'ci/03-maasdeploy.sh') diff --git a/ci/03-maasdeploy.sh b/ci/03-maasdeploy.sh index db60bbfc..fb599e68 100755 --- a/ci/03-maasdeploy.sh +++ b/ci/03-maasdeploy.sh @@ -4,6 +4,24 @@ set -ex source tools.sh + +usage() { + # no xtrace output + { set +x; } 2> /dev/null + + echo "OPNFV JOID deployer of the MAAS (Metal as a Service) infrastructure." + echo "Usage: $0 custom " + echo " $0 virtual" + exit ${1-0} +} + +# Print usage help message if requested +if [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] +then + usage; +fi + + virtinstall=0 labname=$1 @@ -45,22 +63,6 @@ sudo apt-get install bridge-utils openssh-server bzr git virtinst qemu-kvm libvi sudo -H pip install --upgrade pip -usage() { - # no xtrace output - { set +x; } 2> /dev/null - - echo "OPNFV JOID deployer of the MAAS (Metal as a Service) infrastructure." - echo "Usage: $0 custom " - echo " $0 virtual" - exit ${1-0} -} - -if [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] -then - usage; -fi - - # # Config preparation # -- cgit 1.2.3-korg