diff options
author | Martin Schwenke <martin@meltin.net> | 2014-06-20 14:58:37 +1000 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2014-06-25 20:46:16 +1000 |
commit | 36bf4c5f3a91bcb77c1d938f803d91dc6572ce0b (patch) | |
tree | d3d73877b36f5f9aa1b06f409c21178aa81ef302 /autocluster | |
parent | 565c0b5f2d67cd8a7a057909ff62903bf158b226 (diff) | |
download | autocluster-36bf4c5f3a91bcb77c1d938f803d91dc6572ce0b.tar.gz autocluster-36bf4c5f3a91bcb77c1d938f803d91dc6572ce0b.tar.xz autocluster-36bf4c5f3a91bcb77c1d938f803d91dc6572ce0b.zip |
Make cluster name optional for "create cluster"
It can either be specified in the configuration file via the CLUSTER
variable. If it isn't set there then if the configuration file name
is of the form "foo.autocluster" then the cluster name is "foo".
Signed-off-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'autocluster')
-rwxr-xr-x | autocluster | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/autocluster b/autocluster index 655f049..7afb74b 100755 --- a/autocluster +++ b/autocluster @@ -55,7 +55,7 @@ EOF create base create a base image - create cluster CLUSTERNAME + create cluster [ CLUSTERNAME ] create a full cluster create node CLUSTERNAME IP_OFFSET @@ -468,7 +468,9 @@ cluster_created_hooks= create_cluster () { - CLUSTER="$1" + # Use $1. If not set then use value from configuration file. + CLUSTER="${1:-${CLUSTER}}" + [ -n "$CLUSTER" ] || die "\$CLUSTER not set" sanity_check_cluster_name @@ -1191,8 +1193,20 @@ eval set -- "$getopt_output" while true ; do case "$1" in - # force at least ./local_file to avoid accidental file from $PATH - -c) . "$(dirname $2)/$(basename $2)" ; shift 2 ;; + -c) + b=$(basename $2) + # force at least ./local_file to avoid accidental file + # from $PATH + . "$(dirname $2)/${b}" + # If $CLUSTER is unset then try to base it on the filename + if [ ! -n "$CLUSTER" ] ; then + case "$b" in + *.autocluster) + CLUSTER="${b%.autocluster}" + esac + fi + shift 2 + ;; -e) no_sanity=1 ; run_hooks post_config_hooks ; eval "$2" ; exit ;; -E) eval "$2" ; shift 2 ;; -x) set -x; shift ;; |