]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
init-ceph: conditionally update after argparsing
authorAlfredo Deza <alfredo.deza@inktank.com>
Fri, 8 Aug 2014 14:16:20 +0000 (10:16 -0400)
committerSage Weil <sage@redhat.com>
Tue, 12 Aug 2014 19:22:13 +0000 (12:22 -0700)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
src/init-ceph.in

index 8d2ea7a4a055c252aa81b9ff016319d6cd11dcbb..03d0930060bcc15201f38b1d2f9ff78bc440ff9d 100644 (file)
@@ -114,6 +114,8 @@ monaddr=
 dofsmount=1
 dofsumount=0
 verbose=0
+use_default_conf=1
+
 
 while echo $1 | grep -q '^-'; do     # FIXME: why not '^-'?
 case $1 in
@@ -154,6 +156,7 @@ case $1 in
            [ -z "$2" ] && usage_exit
            options="$options $1"
            shift
+        use_default_conf=0
            conf=$1
            ;;
     --cluster )
@@ -177,6 +180,20 @@ options="$options $1"
 shift
 done
 
+
+# if `--cluster` was not passed in, fallback to looking at the config name
+if ! [[ -n "$cluster" ]]; then
+    cluster=`echo $conf | awk -F'/' '{print $(NF)}' | cut -d'.' -f 1`
+else
+    # if we were told to use a given cluster name then $conf needs to be updated
+    # but just define it if `--conf` was not specified, otherwise we would be silently
+    # overriding $conf even if it was defined with `--conf`
+    if [ $use_default_conf -eq 1 ]; then
+        conf="/etc/ceph/$cluster.conf"
+    fi
+fi
+
+
 verify_conf
 
 command=$1
@@ -196,11 +213,6 @@ fi
 for name in $what; do
     type=`echo $name | cut -c 1-3`   # e.g. 'mon', if $item is 'mon1'
     id=`echo $name | cut -c 4- | sed 's/^\\.//'`
-
-    # if `--cluster` was not passed in, fallback to looking at the config name
-    if ! [[ -n "$cluster" ]]; then
-        cluster=`echo $conf | awk -F'/' '{print $(NF)}' | cut -d'.' -f 1`
-    fi
     num=$id
     name="$type.$id"