Can now delete servers (after confirmation).

This commit is contained in:
Marcus Whybrow 2012-05-21 15:59:23 +01:00
parent bef9ce7916
commit 20e786d638

30
msm
View File

@ -96,6 +96,23 @@ manager_create_server() {
fi
}
manager_delete_server() {
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]: "
read answer
if [[ $answer =~ ^y|Y|yes$ ]]; then
# TODO: stop the server if running first
as_user "rm -r $SERVER_STORAGE_PATH/$1"
echo "Server deleted."
else
echo "Server was NOT deleted."
fi
else
echo "No server with that name."
fi
}
manager_jars_group_create() {
if is_valid_name $1; then
if [[ -e $JAR_STORAGE_PATH/$1 ]]; then
@ -199,7 +216,7 @@ manager_jars_group_delete() {
read answer
if [[ $answer =~ ^y|Y|yes$ ]]; then
as_user "rm -r $JAR_STORAGE_PATH/$1"
echo "Jar group was deleted."
echo "Jar group deleted."
else
echo "Jar group was NOT deleted."
fi
@ -222,15 +239,22 @@ case "$1" in
# Required restart option, for debian init.d scripts
;;
create)
# Create a new server
if [ -z $2 ]; then
# If a server name is not provided
echo "Invalid command."
else
# Create a new server
manager_create_server $2
fi
;;
delete)
# Delete an existing server, with confirmation
if [ -z $2 ]; then
# If a server name is not provided
echo "Invalid command."
else
# Delete an existing server, with confirmation
manager_delete_server $2
fi
;;
rename)
# Rename an existing server