-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
stop.sh
executable file
·28 lines (21 loc) · 828 Bytes
/
stop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
SERVER_ROOT_DIR=$(pwd)
source "${SERVER_ROOT_DIR}/scripts/common/paths.sh"
source "${SERVER_SCRIPTS_COMMON_DIR}/status.sh"
source "${SERVER_SCRIPTS_COMMON_DIR}/utils.sh"
REASON="${*}"
SECONDS_BEFORE_KICK=30
if ${IS_SERVER_RUNNING}; then
KICK_REASON="Server shutdown"
run_server_command 'essentials:broadcast Attention everyone!'
send_broadcast_message "The server will be shutting down in a moment..."
if [ -n "${REASON}" ]; then
send_broadcast_message "Reason: ${REASON}"
KICK_REASON="${KICK_REASON} due to: ${REASON}"
fi
run_server_command "essentials:broadcast All online players will be kicked in ${SECONDS_BEFORE_KICK} seconds!"
sleep "${SECONDS_BEFORE_KICK}"
run_server_command kickall "${KICK_REASON}"
run_server_command save-all
papermc stop
fi