Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/start-configuration
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ IFS=$'\n\t'
: "${RCON_CMDS_LAST_DISCONNECT:=}"
: "${RCON_CMDS_PERIOD:=10}"
: "${RCON_PASSWORD_FILE:=}"
: "${ENABLE_RCON:=true}"
: "${RCON_PASSWORD:=minecraft}"
: "${RCON_PORT:=25575}"
export RCON_PASSWORD RCON_PORT
export ENABLE_RCON RCON_PASSWORD RCON_PORT

: "${MEMORY=1G}"
: "${INIT_MEMORY=${MEMORY}}"
Expand Down
48 changes: 26 additions & 22 deletions scripts/start-setupServerProperties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
. "${SCRIPTS:-/}start-utils"

: "${SERVER_PROPERTIES:=/data/server.properties}"
: "${ENABLE_RCON:=true}"
: "${OVERRIDE_SERVER_PROPERTIES:=true}"
: "${SKIP_SERVER_PROPERTIES:=false}"
: "${ENABLE_WHITELIST:=}"

# FUNCTIONS
function setServerPropValue {
Expand Down Expand Up @@ -41,33 +41,18 @@ function setServerProp {
}

function customizeServerProps {
local firstSetup=$1
# Whitelist processing
if [ -n "$WHITELIST" ] || [ -n "$WHITELIST_FILE" ] || isTrue "${ENABLE_WHITELIST:-false}"; then
if [ -n "$WHITELIST" ] || [ -n "$WHITELIST_FILE" ] || isTrue "${ENABLE_WHITELIST}"; then
log "Enabling whitelist functionality"
setServerPropValue "white-list" "true"
setServerPropValue "enforce-whitelist" "true"
else
elif isTrue "$firstSetup" || isFalse "${ENABLE_WHITELIST}"; then
log "Disabling whitelist functionality"
setServerPropValue "white-list" "false"
setServerProp "enforce-whitelist" ENFORCE_WHITELIST
fi

# If not provided, generate a reasonable default message-of-the-day,
# which shows up in the server listing in the client
if ! [ -v 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

# normalize MOTD
if [[ ${TYPE^^} = LIMBO ]]; then
if [[ $MOTD ]] && ! [[ $MOTD =~ ^{ ]]; then
Expand Down Expand Up @@ -123,7 +108,9 @@ function customizeServerProps {
setServerProp "simulation-distance" SIMULATION_DISTANCE
setServerProp "previews-chat" PREVIEWS_CHAT
setServerProp "enforce-secure-profile" ENFORCE_SECURE_PROFILE
setServerPropValue "motd" "$(echo "$MOTD" | mc-image-helper asciify)"
if [[ $MOTD ]]; then
setServerPropValue "motd" "$(echo "$MOTD" | mc-image-helper asciify)"
fi
[[ $LEVEL_TYPE ]] && setServerPropValue "level-type" "${LEVEL_TYPE^^}"

if [ -n "$DIFFICULTY" ]; then
Expand Down Expand Up @@ -213,9 +200,26 @@ fi
if ! isTrue "${SKIP_SERVER_PROPERTIES}"; then
if [ ! -e "$SERVER_PROPERTIES" ]; then
log "Creating server properties in ${SERVER_PROPERTIES}"
customizeServerProps

# If not provided, generate a reasonable default message-of-the-day,
# which shows up in the server listing in the client
if ! [ -v 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

customizeServerProps true
elif isTrue "${OVERRIDE_SERVER_PROPERTIES}"; then
customizeServerProps
customizeServerProps false
else
log "server.properties already created and managed manually"
fi
Expand Down