2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-19 16:05:32 +00:00
|
|
|
. ${SCRIPTS:-/}start-utils
|
2020-03-06 15:52:17 +00:00
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
# FUNCTIONS
|
|
|
|
function setServerProp {
|
|
|
|
local prop=$1
|
|
|
|
local var=$2
|
|
|
|
if [ -n "$var" ]; then
|
2018-04-14 18:01:34 +00:00
|
|
|
# normalize booleans
|
|
|
|
case ${var^^} in
|
|
|
|
TRUE|FALSE)
|
|
|
|
var=${var,,} ;;
|
|
|
|
esac
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}"
|
2019-06-08 21:47:28 +00:00
|
|
|
sed -i "/^${prop}\s*=/ c ${prop}=${var}" "$SERVER_PROPERTIES"
|
2018-01-28 12:16:45 +00:00
|
|
|
else
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Skip setting ${prop}"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-04-03 20:23:19 +00:00
|
|
|
function customizeServerProps {
|
2017-11-01 05:42:44 +00:00
|
|
|
if [ -n "$WHITELIST" ]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Creating whitelist"
|
2018-01-28 12:16:45 +00:00
|
|
|
setServerProp "whitelist" "true"
|
|
|
|
setServerProp "white-list" "true"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
2018-04-14 18:52:46 +00:00
|
|
|
# If not provided, generate a reasonable default message-of-the-day,
|
|
|
|
# which shows up in the server listing in the client
|
2018-12-02 23:52:23 +00:00
|
|
|
if [ -z "$MOTD" ]; then
|
2018-04-14 18:52:46 +00:00
|
|
|
# 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
|
|
|
|
|
2019-01-12 15:32:30 +00:00
|
|
|
setServerProp "server-name" "$SERVER_NAME"
|
2020-03-20 14:56:50 +00:00
|
|
|
setServerProp "server-ip" "$SERVER_IP"
|
2018-02-12 16:26:44 +00:00
|
|
|
setServerProp "server-port" "$SERVER_PORT"
|
2017-11-01 05:42:44 +00:00
|
|
|
setServerProp "motd" "$MOTD"
|
|
|
|
setServerProp "allow-nether" "$ALLOW_NETHER"
|
|
|
|
setServerProp "announce-player-achievements" "$ANNOUNCE_PLAYER_ACHIEVEMENTS"
|
|
|
|
setServerProp "enable-command-block" "$ENABLE_COMMAND_BLOCK"
|
|
|
|
setServerProp "spawn-animals" "$SPAWN_ANIMALS"
|
|
|
|
setServerProp "spawn-monsters" "$SPAWN_MONSTERS"
|
|
|
|
setServerProp "spawn-npcs" "$SPAWN_NPCS"
|
2019-09-08 21:40:45 +00:00
|
|
|
setServerProp "spawn-protection" "$SPAWN_PROTECTION"
|
2017-11-01 05:42:44 +00:00
|
|
|
setServerProp "generate-structures" "$GENERATE_STRUCTURES"
|
|
|
|
setServerProp "view-distance" "$VIEW_DISTANCE"
|
|
|
|
setServerProp "hardcore" "$HARDCORE"
|
2018-05-19 23:07:16 +00:00
|
|
|
setServerProp "snooper-enabled" "$SNOOPER_ENABLED"
|
2017-11-01 05:42:44 +00:00
|
|
|
setServerProp "max-build-height" "$MAX_BUILD_HEIGHT"
|
|
|
|
setServerProp "force-gamemode" "$FORCE_GAMEMODE"
|
2018-07-24 06:13:47 +00:00
|
|
|
setServerProp "max-tick-time" "$MAX_TICK_TIME"
|
2017-11-01 05:42:44 +00:00
|
|
|
setServerProp "enable-query" "$ENABLE_QUERY"
|
|
|
|
setServerProp "query.port" "$QUERY_PORT"
|
|
|
|
setServerProp "enable-rcon" "$ENABLE_RCON"
|
|
|
|
setServerProp "rcon.password" "$RCON_PASSWORD"
|
|
|
|
setServerProp "rcon.port" "$RCON_PORT"
|
|
|
|
setServerProp "max-players" "$MAX_PLAYERS"
|
|
|
|
setServerProp "max-world-size" "$MAX_WORLD_SIZE"
|
|
|
|
setServerProp "level-name" "$LEVEL"
|
|
|
|
setServerProp "level-seed" "$SEED"
|
|
|
|
setServerProp "pvp" "$PVP"
|
|
|
|
setServerProp "generator-settings" "$GENERATOR_SETTINGS"
|
|
|
|
setServerProp "online-mode" "$ONLINE_MODE"
|
2018-04-14 18:01:34 +00:00
|
|
|
setServerProp "allow-flight" "$ALLOW_FLIGHT"
|
2018-10-06 13:08:13 +00:00
|
|
|
setServerProp "level-type" "${LEVEL_TYPE^^}"
|
2019-08-24 15:38:59 +00:00
|
|
|
setServerProp "resource-pack" "$RESOURCE_PACK"
|
|
|
|
setServerProp "resource-pack-sha1" "$RESOURCE_PACK_SHA1"
|
2020-04-16 16:40:49 +00:00
|
|
|
setServerProp "player-idle-timeout" "$PLAYER_IDLE_TIMEOUT"
|
2020-07-04 19:52:35 +00:00
|
|
|
setServerProp "broadcast-console-to-ops" "$BROADCAST_CONSOLE_TO_OPS"
|
|
|
|
setServerProp "broadcast-rcon-to-ops" "$BROADCAST_RCON_TO_OPS"
|
|
|
|
setServerProp "enable-jmx-monitoring" "$ENABLE_JMX"
|
|
|
|
setServerProp "sync-chunk-writes" "$SYNC_CHUNK_WRITES"
|
|
|
|
setServerProp "enable-status" "$ENABLE_STATUS"
|
|
|
|
setServerProp "entity-broadcast-range-percentage" "$ENTITY_BROADCAST_RANGE_PERCENTAGE"
|
|
|
|
setServerProp "function-permission-level" "$FUNCTION_PERMISSION_LEVEL"
|
|
|
|
setServerProp "network-compression-threshold" "$NETWORK_COMPRESSION_THRESHOLD"
|
|
|
|
setServerProp "op-permission-level" "$OP_PERMISSION_LEVEL"
|
|
|
|
setServerProp "prevent-proxy-connections" "$PREVENT_PROXY_CONNECTIONS"
|
|
|
|
setServerProp "use-native-transport" "$USE_NATIVE_TRANSPORT"
|
|
|
|
setServerProp "enforce-whitelist" "$ENFORCE_WHITELIST"
|
2017-11-01 05:42:44 +00:00
|
|
|
|
|
|
|
if [ -n "$DIFFICULTY" ]; then
|
|
|
|
case $DIFFICULTY in
|
|
|
|
peaceful|0)
|
2020-04-22 12:06:57 +00:00
|
|
|
if versionLessThan 1.13; then
|
|
|
|
DIFFICULTY=0
|
|
|
|
else
|
|
|
|
DIFFICULTY=peaceful
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
easy|1)
|
2020-04-22 12:06:57 +00:00
|
|
|
if versionLessThan 1.13; then
|
|
|
|
DIFFICULTY=1
|
|
|
|
else
|
|
|
|
DIFFICULTY=easy
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
normal|2)
|
2020-04-22 12:06:57 +00:00
|
|
|
if versionLessThan 1.13; then
|
|
|
|
DIFFICULTY=2
|
|
|
|
else
|
|
|
|
DIFFICULTY=normal
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
hard|3)
|
2020-04-22 12:06:57 +00:00
|
|
|
if versionLessThan 1.13; then
|
|
|
|
DIFFICULTY=3
|
|
|
|
else
|
|
|
|
DIFFICULTY=hard
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
*)
|
2020-03-06 15:52:17 +00:00
|
|
|
log "DIFFICULTY must be peaceful, easy, normal, or hard."
|
2017-11-01 05:42:44 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2018-01-28 12:16:45 +00:00
|
|
|
setServerProp "difficulty" "$DIFFICULTY"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$MODE" ]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Setting mode"
|
2017-11-01 05:42:44 +00:00
|
|
|
MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
|
|
|
|
case $MODE_LC in
|
2020-04-22 12:06:57 +00:00
|
|
|
su*|0)
|
|
|
|
if versionLessThan 1.13; then
|
|
|
|
MODE=0
|
|
|
|
else
|
|
|
|
MODE=survival
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
2020-04-22 12:06:57 +00:00
|
|
|
c*|1)
|
|
|
|
if versionLessThan 1.13; then
|
|
|
|
MODE=1
|
|
|
|
else
|
|
|
|
MODE=creative
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
2020-04-22 12:06:57 +00:00
|
|
|
a*|2)
|
|
|
|
if versionLessThan 1.13; then
|
|
|
|
MODE=2
|
|
|
|
else
|
|
|
|
MODE=adventure
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
2020-04-22 12:06:57 +00:00
|
|
|
sp*|3)
|
|
|
|
if versionLessThan 1.13; then
|
|
|
|
MODE=3
|
|
|
|
else
|
|
|
|
MODE=spectator
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
*)
|
2020-03-06 15:52:17 +00:00
|
|
|
log "ERROR: Invalid game mode: $MODE"
|
2017-11-01 05:42:44 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2018-01-28 13:45:25 +00:00
|
|
|
setServerProp "gamemode" "$MODE"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
2019-04-03 20:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Deploy server.properties file
|
|
|
|
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
|
|
|
export SERVER_PROPERTIES=${FTB_DIR}/server.properties
|
2020-03-06 15:52:17 +00:00
|
|
|
log "detected FTB, changing properties path to ${SERVER_PROPERTIES}"
|
2019-04-03 20:23:19 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-08 21:47:28 +00:00
|
|
|
if [ ! -e "$SERVER_PROPERTIES" ]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Creating server.properties in ${SERVER_PROPERTIES}"
|
2019-06-08 21:47:28 +00:00
|
|
|
cp /tmp/server.properties "$SERVER_PROPERTIES"
|
2019-04-03 20:23:19 +00:00
|
|
|
customizeServerProps
|
|
|
|
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
|
|
|
|
case ${OVERRIDE_SERVER_PROPERTIES^^} in
|
|
|
|
TRUE|1)
|
|
|
|
customizeServerProps
|
|
|
|
;;
|
|
|
|
*)
|
2020-03-06 15:52:17 +00:00
|
|
|
log "server.properties already created, skipping"
|
2019-04-03 20:23:19 +00:00
|
|
|
;;
|
|
|
|
esac
|
2018-01-28 13:45:25 +00:00
|
|
|
else
|
2020-03-06 15:52:17 +00:00
|
|
|
log "server.properties already created, skipping"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
2020-05-20 13:17:58 +00:00
|
|
|
if isTrue "${ENABLE_AUTOPAUSE}"; then
|
|
|
|
current_max_tick=$( grep 'max-tick-time' "$SERVER_PROPERTIES" | sed -r 's/( )+//g' | awk -F= '{print $2}' )
|
|
|
|
if (( $current_max_tick > 0 && $current_max_tick < 86400000 )); then
|
|
|
|
log "Warning: The server.properties for the server doesn't have the Server Watchdog (effectively) disabled."
|
|
|
|
log "Warning (cont): Autopause functionality resuming the process might trigger the Watchdog and restart the server completely."
|
|
|
|
log "Warning (cont): Set the max-tick-time property to a high value (or disable the Watchdog with value -1 for versions 1.8.1+)."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-06-14 16:14:11 +00:00
|
|
|
if isDebugging; then
|
|
|
|
log "DEBUG Dumping server.properties"
|
|
|
|
cat /data/server.properties
|
|
|
|
fi
|
|
|
|
|
2020-06-19 16:05:32 +00:00
|
|
|
exec ${SCRIPTS:-/}start-finalSetup05EnvVariables $@
|