]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mkcephfs.in: print out usage if no actions given
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 25 May 2011 01:16:08 +0000 (18:16 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 25 May 2011 01:16:08 +0000 (18:16 -0700)
If the user didn't specify any actions, print out a usage message rather
than silently exiting.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/mkcephfs.in

index 0e0ca6e59505452d626ce8914abf58d06ff69f55..54e4352305ed9f570255b9f9ba3adcb8477534db 100644 (file)
@@ -86,6 +86,8 @@ adminkeyring=""
 conf=""
 dir=""
 moreargs=""
+auto_action=0
+manual_action=0
 
 while [ $# -ge 1 ]; do
 case $1 in
@@ -99,27 +101,33 @@ case $1 in
            ;;
     --allhosts | -a)
            allhosts=1
+            auto_action=1
            ;;
     --prepare-monmap)
            preparemonmap=1
+            manual_action=1
            ;;
     --prepare-osdfs)
            [ -z "$2" ] && usage_exit
            shift
            prepareosdfs=$1
+            manual_action=1
            ;;
     --init-daemon)
            [ -z "$2" ] && usage_exit
            shift
            initdaemon=$1
+            manual_action=1
            ;;
     --init-local-daemons)
            [ -z "$2" ] && usage_exit
            shift
            initlocaldaemons=$1
+            manual_action=1
            ;;
     --prepare-mon)
            preparemon=1
+            manual_action=1
            ;;
     --mkbtrfs)
            mkbtrfs=1
@@ -169,15 +177,16 @@ done
 
 [ -z "$conf" ] && [ -n "$dir" ] && conf="$dir/conf"
 
-if [ $allhosts -eq 1 ]; then
-    if [ $preparemonmap -eq 1 ] || [ -n "$initdaemon" ] || [ -n "$initlocaldaemons" ] || [ -n "$prepareosdfs" ] || [ -n "$preparemon" ] ; then
-       echo "The -a option cannot be combined with other subcommands; see man page."
-       usage_exit
+if [ $manual_action -eq 0 ]; then
+    if [ $auto_action -eq 0 ]; then
+        echo "You must specify an action. See man page."
+        usage_exit
     fi
+elif [ $auto_action -eq 1 ]; then
+    echo "The -a option cannot be combined with other subcommands; see man page."
+    usage_exit
 fi
 
-
-
 ### prepare-monmap ###
 
 if [ $preparemonmap -eq 1 ]; then