diff options
author | TheMightyV <themightyv@protonmail.com> | 2022-01-05 19:48:16 +0100 |
---|---|---|
committer | TheMightyV <themightyv@protonmail.com> | 2022-01-05 19:48:16 +0100 |
commit | 9a80e613c6838b5c73d2e18237c6547fa8ec3dfc (patch) | |
tree | 1f53ee10e43c1cface734b34f75e27f64c664f5c /server.sh | |
parent | 66f9d91a93148d607e791fc98d14b38c584ea0ea (diff) | |
download | minecraft-server-tools-9a80e613c6838b5c73d2e18237c6547fa8ec3dfc.tar.gz |
flipped asserts to match "canon" assert behaviour
added "server not running" check in server_restore
Diffstat (limited to 'server.sh')
-rwxr-xr-x | server.sh | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -26,7 +26,7 @@ function send_cmd () { tmux -S $TMUX_SOCKET send -t $TMUX_WINDOW "$1" enter } -function assert_running() { +function assert_not_running() { if server_running; then echo "It seems a server is already running. If this is not the case,\ manually attach to the running screen and close it." @@ -34,7 +34,7 @@ function assert_running() { fi } -function assert_not_running() { +function assert_running() { if ! server_running; then echo "Server not running" exit 1 @@ -42,7 +42,7 @@ function assert_not_running() { } function server_start() { - assert_running + assert_not_running if [ ! -f "eula.txt" ] then @@ -62,7 +62,7 @@ function server_stop() { # Allow success even if server is not running #trap "exit 0" EXIT - assert_not_running + assert_running send_cmd "stop" local RET=1 @@ -81,7 +81,7 @@ function server_stop() { } function server_attach() { - assert_not_running + assert_running tmux -S $TMUX_SOCKET attach -t $TMUX_WINDOW exit } @@ -302,6 +302,8 @@ function is_in() { } function server_restore() { + assert_not_running + local backup_dir local snapshot_index local dest="$PWD" @@ -363,7 +365,6 @@ function server_restore() { echo_debug "Restoring snapshot \"$snapshot\" from \"$backup_dir\"" - # if we restore to PWD, we will overwrite the current world, which might be harmful local oldworld_name if [ "$dest" = "$PWD" ] && [[ -d "$WORLD_NAME" ]]; then |