Can now list existing servers.

This commit is contained in:
Marcus Whybrow 2012-05-21 18:34:12 +01:00
parent 1ceea5bd59
commit fd44c3134f

25
msm
View File

@ -86,9 +86,16 @@ get_latest_file() {
} }
### Manager Functions ### Server Functions
manager_create_server() { server_list() {
echo "Servers:"
for server in "$SERVER_STORAGE_PATH/*"; do
echo " $(basename $server)"
done
}
server_create() {
if is_valid_name "$1"; then if is_valid_name "$1"; then
if [[ -e "$SERVER_STORAGE_PATH/$1" ]]; then if [[ -e "$SERVER_STORAGE_PATH/$1" ]]; then
echo "A server with that name already exists." echo "A server with that name already exists."
@ -106,7 +113,7 @@ manager_create_server() {
fi fi
} }
manager_delete_server() { server_delete() {
if is_valid_name "$1" && [[ -e "$SERVER_STORAGE_PATH/$1" ]]; then if is_valid_name "$1" && [[ -e "$SERVER_STORAGE_PATH/$1" ]]; then
printf "Are you sure you want to delete this server and its worlds (note: backups are preserved) [y/N]: " printf "Are you sure you want to delete this server and its worlds (note: backups are preserved) [y/N]: "
@ -126,7 +133,7 @@ manager_delete_server() {
fi fi
} }
manager_rename_server() { server_rename() {
if is_valid_name "$1" && [[ -e "$SERVER_STORAGE_PATH/$1" ]]; then if is_valid_name "$1" && [[ -e "$SERVER_STORAGE_PATH/$1" ]]; then
# If the server name is valid, # If the server name is valid,
# and there is no other server with the name $1 # and there is no other server with the name $1
@ -152,6 +159,9 @@ manager_rename_server() {
fi fi
} }
### Jar Group Functions
jargroup_create() { jargroup_create() {
if is_valid_name "$1"; then if is_valid_name "$1"; then
if [[ -e "$JAR_STORAGE_PATH/$1" ]]; then if [[ -e "$JAR_STORAGE_PATH/$1" ]]; then
@ -283,6 +293,7 @@ case "$1" in
server) server)
case "$2" in case "$2" in
list) list)
server_list
;; ;;
create) create)
if [ -z "$3" ]; then if [ -z "$3" ]; then
@ -290,7 +301,7 @@ case "$1" in
echo "Invalid command." echo "Invalid command."
else else
# Create a new server # Create a new server
manager_create_server "$3" server_create "$3"
fi fi
;; ;;
delete) delete)
@ -299,7 +310,7 @@ case "$1" in
echo "Invalid command." echo "Invalid command."
else else
# Delete an existing server, with confirmation # Delete an existing server, with confirmation
manager_delete_server "$3" server_delete "$3"
fi fi
;; ;;
rename) rename)
@ -308,7 +319,7 @@ case "$1" in
echo "Invalid command." echo "Invalid command."
else else
# Rename an existing server # Rename an existing server
manager_rename_server "$3" "$4" server_rename "$3" "$4"
fi fi
;; ;;
*) *)