Skip to content

Commit 74cb61c

Browse files
committed
Added pre-start and pre-stop hooks
1 parent a5f6230 commit 74cb61c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

msctl

+21
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,17 @@ startServerMonitor() {
14531453
start() {
14541454
local EULA PID SERVER_COMMAND WORLD_DIR
14551455
WORLD_DIR="$WORLDS_LOCATION/$1"
1456+
1457+
# Pre-start Hook script execution
1458+
PRE_START_HOOK="$WORLD_DIR/hooks/pre-start.sh"
1459+
if [ -x "$PRE_START_HOOK" ]; then
1460+
printf "Executing pre-start hook script for world %s...\n" "$1"
1461+
"$PRE_START_HOOK"
1462+
if [ $? -ne 0 ]; then
1463+
printf "Warning: pre-start hook script for world %s exited with a non-zero status.\n" "$1"
1464+
fi
1465+
fi
1466+
14561467
# Make sure that the server software exists.
14571468
updateServerSoftware "$1"
14581469
# Make sure that the world's directory exists.
@@ -1566,6 +1577,16 @@ start() {
15661577
# @param 1 The world server to stop.
15671578
# ---------------------------------------------------------------------------
15681579
stop() {
1580+
# Pre-stop Hook script execution
1581+
PRE_STOP_HOOK="$WORLDS_LOCATION/$1/hooks/pre-stop.sh"
1582+
if [ -x "$PRE_STOP_HOOK" ]; then
1583+
printf "Executing pre-stop hook script for world %s...\n" "$1"
1584+
"$PRE_STOP_HOOK"
1585+
if [ $? -ne 0 ]; then
1586+
printf "Warning: pre-stop hook script for world %s exited with a non-zero status.\n" "$1"
1587+
fi
1588+
fi
1589+
15691590
# Stop the server monitor if it is running.
15701591
stopServerMonitor $1
15711592
# Tell the server to stop.

0 commit comments

Comments
 (0)