Skip to content

Commit a5f6230

Browse files
committed
Adding hook scritps to start, stop and force-stop. The scripts are executed, if they exists: hooks/post-start.sh - hooks/post-stop.sh
1 parent 4cbc423 commit a5f6230

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

msctl

+20-1
Original file line numberDiff line numberDiff line change
@@ -1549,8 +1549,17 @@ start() {
15491549
echo $PID >"$WORLDS_LOCATION/$1.pid"
15501550
# Start the server crash monitor, if enabled.
15511551
startServerMonitor $1
1552-
}
15531552

1553+
# Hook script execution
1554+
HOOK_SCRIPT="$WORLD_DIR/hooks/post-start.sh"
1555+
if [ -x "$HOOK_SCRIPT" ]; then
1556+
printf "Executing post-start hook script for world %s...\n" "$1"
1557+
"$HOOK_SCRIPT"
1558+
if [ $? -ne 0 ]; then
1559+
printf "Warning: post-start hook script for world %s exited with a non-zero status.\n" "$1"
1560+
fi
1561+
fi
1562+
}
15541563
# ---------------------------------------------------------------------------
15551564
# Stop the world server.
15561565
#
@@ -1578,6 +1587,16 @@ stop() {
15781587
fi
15791588
# Remove the PID file for the world server.
15801589
rm -f "$WORLDS_LOCATION/$1.pid"
1590+
1591+
# Hook script execution
1592+
HOOK_SCRIPT="$WORLDS_LOCATION/$1/hooks/post-stop.sh"
1593+
if [ -x "$HOOK_SCRIPT" ]; then
1594+
printf "Executing post-stop hook script for world %s...\n" "$1"
1595+
"$HOOK_SCRIPT"
1596+
if [ $? -ne 0 ]; then
1597+
printf "Warning: post-stop hook script for world %s exited with a non-zero status.\n" "$1"
1598+
fi
1599+
fi
15811600
}
15821601

15831602
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)