@@ -1453,6 +1453,17 @@ startServerMonitor() {
1453
1453
start () {
1454
1454
local EULA PID SERVER_COMMAND WORLD_DIR
1455
1455
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
+
1456
1467
# Make sure that the server software exists.
1457
1468
updateServerSoftware " $1 "
1458
1469
# Make sure that the world's directory exists.
@@ -1549,14 +1560,33 @@ start() {
1549
1560
echo $PID > " $WORLDS_LOCATION /$1 .pid"
1550
1561
# Start the server crash monitor, if enabled.
1551
1562
startServerMonitor $1
1552
- }
1553
1563
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
+ }
1554
1574
# ---------------------------------------------------------------------------
1555
1575
# Stop the world server.
1556
1576
#
1557
1577
# @param 1 The world server to stop.
1558
1578
# ---------------------------------------------------------------------------
1559
1579
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
+
1560
1590
# Stop the server monitor if it is running.
1561
1591
stopServerMonitor $1
1562
1592
# Tell the server to stop.
@@ -1578,6 +1608,16 @@ stop() {
1578
1608
fi
1579
1609
# Remove the PID file for the world server.
1580
1610
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
1581
1621
}
1582
1622
1583
1623
# ---------------------------------------------------------------------------
0 commit comments