Merge pull request #185 from IronTetsubo/pull1

Make sure a server is stopped before deleting it
This commit is contained in:
Marcus Whybrow 2013-09-02 15:13:09 -07:00
commit 1037373392

View File

@ -1261,11 +1261,17 @@ server_delete() {
manager_property USERNAME
if [[ -d "$SETTINGS_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 server \"$1\" and its worlds? (note: backups are preserved) [y/N]: "
read answer
if [[ "$answer" =~ ^(y|Y|yes)$ ]]; then
# TODO: stop the server if running first
server_get_id "$1"
local existing_id="$RETURN"
if server_is_running "$existing_id"; then
echo "Server \"$1\" is running."
server_stop_now "$existing_id"
fi
as_user "$SETTINGS_USERNAME" "rm -rf '$SETTINGS_SERVER_STORAGE_PATH/$1'"
echo "Server deleted."
else