mc: compute default MOTD based on the given type and version

This commit is contained in:
Geoff Bourne 2018-04-14 13:52:46 -05:00
parent 1f04ca946c
commit 5267927c3f
4 changed files with 26 additions and 3 deletions

View File

@ -41,7 +41,6 @@ WORKDIR /data
ENTRYPOINT [ "/start" ]
ENV UID=1000 GID=1000 \
MOTD="A Minecraft Server Powered by Docker" \
JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= LEVEL=world \
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \

View File

@ -628,8 +628,14 @@ The message of the day, shown below each server entry in the UI, can be changed
docker run -d -e 'MOTD=My Server' ...
If you leave it off, the last used or default message will be used. _The example shows how to specify a server
message of the day that contains spaces by putting quotes around the whole thing._
If you leave it off, a default is computed from the server type and version, such as
A Paper Minecraft Server powered by Docker
when `TYPE` is `PAPER`. That way you can easily differentiate between several servers you may have started.
_The example shows how to specify a server message of the day that contains spaces by putting quotes
around the whole thing._
### PVP Mode

View File

@ -58,6 +58,8 @@ esac
cd /data
export ORIGINAL_TYPE=${TYPE}
echo "Checking type information."
case "$TYPE" in
*BUKKIT|*bukkit|SPIGOT|spigot)

View File

@ -34,6 +34,22 @@ if [ ! -e $SERVER_PROPERTIES ]; then
setServerProp "white-list" "true"
fi
# If not provided, generate a reasonable default message-of-the-day,
# which shows up in the server listing in the client
if [ -z $MOTD ]; then
# snapshot is the odd case where we have to look at version to identify that label
if [[ ${ORIGINAL_TYPE} == "VANILLA" && ${VERSION} == "SNAPSHOT" ]]; then
label=SNAPSHOT
else
label=${ORIGINAL_TYPE}
fi
# Convert label to title-case
label=${label,,}
label=${label^}
MOTD="A ${label} Minecraft Server powered by Docker"
fi
setServerProp "server-port" "$SERVER_PORT"
setServerProp "motd" "$MOTD"
setServerProp "allow-nether" "$ALLOW_NETHER"