@@ -1453,6 +1453,17 @@ startServerMonitor() {
14531453start () {
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.
@@ -1549,14 +1560,33 @@ start() {
15491560 echo $PID > " $WORLDS_LOCATION /$1 .pid"
15501561 # Start the server crash monitor, if enabled.
15511562 startServerMonitor $1
1552- }
15531563
1564+ # Hook script execution
1565+ HOOK_SCRIPT=" $WORLD_DIR /hooks/post-start.sh"
1566+ if [ -x " $HOOK_SCRIPT " ]; then
1567+ printf " Executing post-start hook script for world %s...\n" " $1 "
1568+ " $HOOK_SCRIPT "
1569+ if [ $? -ne 0 ]; then
1570+ printf " Warning: post-start hook script for world %s exited with a non-zero status.\n" " $1 "
1571+ fi
1572+ fi
1573+ }
15541574# ---------------------------------------------------------------------------
15551575# Stop the world server.
15561576#
15571577# @param 1 The world server to stop.
15581578# ---------------------------------------------------------------------------
15591579stop () {
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+
15601590 # Stop the server monitor if it is running.
15611591 stopServerMonitor $1
15621592 # Tell the server to stop.
@@ -1578,6 +1608,16 @@ stop() {
15781608 fi
15791609 # Remove the PID file for the world server.
15801610 rm -f " $WORLDS_LOCATION /$1 .pid"
1611+
1612+ # Hook script execution
1613+ HOOK_SCRIPT=" $WORLDS_LOCATION /$1 /hooks/post-stop.sh"
1614+ if [ -x " $HOOK_SCRIPT " ]; then
1615+ printf " Executing post-stop hook script for world %s...\n" " $1 "
1616+ " $HOOK_SCRIPT "
1617+ if [ $? -ne 0 ]; then
1618+ printf " Warning: post-stop hook script for world %s exited with a non-zero status.\n" " $1 "
1619+ fi
1620+ fi
15811621}
15821622
15831623# ---------------------------------------------------------------------------
0 commit comments