From 075149ca1d343e37e81afb097a752f8f25dfdfd5 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 19 Oct 2012 12:22:59 +0100 Subject: [PATCH] Improve option handling. * Add support to specify the git branch or revision that should be checked out. * We now `shift` arguments as they are used. Once we've handled them all, if there are still arguments remaining, fail. * Minor `echo` changes. --- bootstrap-salt-minion.sh | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/bootstrap-salt-minion.sh b/bootstrap-salt-minion.sh index ec18d86..8cfd4fc 100755 --- a/bootstrap-salt-minion.sh +++ b/bootstrap-salt-minion.sh @@ -27,13 +27,21 @@ ScriptVersion="1.0" usage() { cat << EOT - Usage : ${0##/*/} [options] + Usage : ${0##/*/} [options] Installation types: - stable (default) - - daily + - daily (ubuntu specific) - git + Examples: + $ ${0##/*/} + $ ${0##/*/} stable + $ ${0##/*/} daily + $ ${0##/*/} git + $ ${0##/*/} git develop + $ ${0##/*/} git 8c3fadf15ec183e5ce8c63739850d543617e4357 + Options: -h|help Display this message -v|version Display script version @@ -64,6 +72,7 @@ if [ "$#" -eq 0 ];then ITYPE="stable" else ITYPE=$1 + shift fi if [ "$ITYPE" != "stable" -a "$ITYPE" != "daily" -a "$ITYPE" != "git" ]; then @@ -71,6 +80,22 @@ if [ "$ITYPE" != "stable" -a "$ITYPE" != "daily" -a "$ITYPE" != "git" ]; then exit 1 fi +if [ $ITYPE = "git" ]; then + if [ "$#" -eq 0 ];then + GIT_REV="master" + else + GIT_REV=$1 + shift + fi +fi + +if [ "$#" -gt 0 ]; then + usage + echo + echo " * ERROR: Too many arguments." + exit 1 +fi + # Root permissions are required to run this script if [ $(whoami) != "root" ] ; then echo " * ERROR: Salt requires root privileges to install. Please re-run this script as root." @@ -261,11 +286,11 @@ __function_defined() { } __gather_system_info -echo " System Information:" -echo " OS Name: ${OS_NAME}" -echo " OS Version: ${OS_VERSION}" -echo " Machine: ${MACHINE}" -echo " Distribution: ${DISTRO_NAME} ${DISTRO_VERSION}" +echo " * System Information:" +echo " OS Name: ${OS_NAME}" +echo " OS Version: ${OS_VERSION}" +echo " Machine: ${MACHINE}" +echo " Distribution: ${DISTRO_NAME} ${DISTRO_VERSION}" # Simplify version naming on functions