From bef9ce7916eefc3524eac7c8ef087173fade7e53 Mon Sep 17 00:00:00 2001 From: Marcus Whybrow Date: Mon, 21 May 2012 15:52:31 +0100 Subject: [PATCH] Validation checks for create and server commands. --- msm | 90 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/msm b/msm index 0888d2d..bc967ec 100755 --- a/msm +++ b/msm @@ -223,7 +223,11 @@ case "$1" in ;; create) # Create a new server - manager_create_server $2 + if [ -z $2 ]; then + echo "Invalid command." + else + manager_create_server $2 + fi ;; delete) # Delete an existing server, with confirmation @@ -316,46 +320,50 @@ case "$1" in *) # TODO: Check first if $1 is an existing server name - case "$2" in - start) - ;; - stop) - ;; - restart) - ;; - worlds) - ;; - backup) - ;; - logroll) - ;; - connected) - ;; - status) - ;; - whitelist|wl) - ;; - blacklist|bl) - ;; - operator|op) - ;; - gamemode|gm) - ;; - kick) - ;; - say) - ;; - "time") - ;; - toggledownfall) - ;; - save) - ;; - cmd) - ;; - cmdlog) - ;; - esac + if is_valid_name "$1" && [[ -e $SERVER_STORAGE_PATH/$1 ]]; then + case "$2" in + start) + ;; + stop) + ;; + restart) + ;; + worlds) + ;; + backup) + ;; + logroll) + ;; + connected) + ;; + status) + ;; + whitelist|wl) + ;; + blacklist|bl) + ;; + operator|op) + ;; + gamemode|gm) + ;; + kick) + ;; + say) + ;; + "time") + ;; + toggledownfall) + ;; + save) + ;; + cmd) + ;; + cmdlog) + ;; + esac + else + echo "No server with that name." + fi ;; esac