diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 035e7812..57facc00 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -24,9 +24,17 @@ body: attributes: label: Container definition description: Please provide the compose file or run command used to create the container + value: | + ``` + Paste run command or compose file here + ``` - type: textarea id: logs attributes: label: Container logs description: | - Please provide container logs from the start of the container, which will be the ones prefixed with `[init]`. It is even better if you can set the variable `DEBUG` to "true" and provide those debug container logs. \ No newline at end of file + Please provide container logs from the start of the container, which will be the ones prefixed with `[init]`. It is even better if you can set the variable `DEBUG` to "true" and provide those debug container logs. + value: | + ``` + Paste logs here + ``` \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..adc9c92a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,7 @@ +contact_links: + - name: Ask a question in discussions + url: https://github.com/itzg/docker-minecraft-server/discussions + about: Please ask questions here + - name: Ask a question on Discord + url: https://discord.gg/DXfKpjB + about: Please ask questions here \ No newline at end of file diff --git a/.github/workflows/build-multiarch.yml b/.github/workflows/build-multiarch.yml index d61203a9..7ca171d7 100644 --- a/.github/workflows/build-multiarch.yml +++ b/.github/workflows/build-multiarch.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2.3.5 + uses: actions/checkout@v2.4.0 - name: Docker meta id: meta diff --git a/.github/workflows/generate-toc.yml b/.github/workflows/generate-toc.yml index cc95dbf7..d5f6e76c 100644 --- a/.github/workflows/generate-toc.yml +++ b/.github/workflows/generate-toc.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@v2.3.5 + - uses: actions/checkout@v2.4.0 - run: | curl https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc -o gh-md-toc chmod a+x gh-md-toc diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cfd228b7..bebc752a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2.3.5 + - uses: actions/checkout@v2.4.0 - name: Run tests run: | @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2.3.5 + - uses: actions/checkout@v2.4.0 - name: Prepare id: prep diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 719067d6..0bcd9c96 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.5 + - uses: actions/checkout@v2.4.0 - name: Run tests run: | diff --git a/Dockerfile b/Dockerfile index e11a8c85..09bb574a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,6 @@ ENV UID=1000 GID=1000 \ MEMORY="1G" \ TYPE=VANILLA VERSION=LATEST \ ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \ - SERVER_PORT=25565 ONLINE_MODE=TRUE SERVER_NAME="Dedicated Server" \ ENABLE_AUTOPAUSE=false AUTOPAUSE_TIMEOUT_EST=3600 AUTOPAUSE_TIMEOUT_KN=120 AUTOPAUSE_TIMEOUT_INIT=600 \ AUTOPAUSE_PERIOD=10 AUTOPAUSE_KNOCK_INTERFACE=eth0 diff --git a/README.md b/README.md index 411460b4..2823e194 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ By default, the container will download the latest version of the "vanilla" [Min * [Running on RaspberryPi](#running-on-raspberrypi) * [Contributing](#contributing) - + @@ -808,6 +808,8 @@ This will reset any manual configuration of the `server.properties` file, so if In the opposite case, you can skip the startup script's creation of `server.properties`, by setting `SKIP_SERVER_PROPERTIES` to "true". +> NOTE: to clear a server property, set the variable to an empty string, such as `-e RESOURCE_PACK=""`. A variables that maps to a server property that is unset, is ignored and the existing `server.property` is left unchanged. + ### Message of the Day The message of the day, shown below each server entry in the client UI, can be changed with the `MOTD` environment variable, such as diff --git a/scripts/start-deployVanilla b/scripts/start-deployVanilla index ed8eadbc..291f0f64 100755 --- a/scripts/start-deployVanilla +++ b/scripts/start-deployVanilla @@ -47,6 +47,8 @@ if versionLessThan 1.6; then ln -s "/data/$SERVER" /data/minecraft_server.jar fi SERVER=minecraft_server.jar +elif [[ -L /data/minecraft_server.jar ]]; then + rm -f /data/minecraft_server.jar fi isDebugging && ls -l diff --git a/scripts/start-setupServerProperties b/scripts/start-setupServerProperties index 3e67e6bf..38aa7030 100755 --- a/scripts/start-setupServerProperties +++ b/scripts/start-setupServerProperties @@ -1,40 +1,46 @@ #!/bin/bash -. ${SCRIPTS:-/}start-utils +# shellcheck source=start-utils +. "${SCRIPTS:-/}start-utils" -: ${SERVER_PROPERTIES:=/data/server.properties} +: "${SERVER_PROPERTIES:=/data/server.properties}" # FUNCTIONS +function setServerPropValue { + local prop=$1 + local value=$2 + # normalize booleans + case ${value^^} in + TRUE|FALSE) + value=${value,,} ;; + esac + if grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then + log "Setting ${prop} to '${value}' in ${SERVER_PROPERTIES}" + sed -i "/^${prop}\s*=/ c ${prop}=${value//\\/\\\\}" "$SERVER_PROPERTIES" + else + log "Adding ${prop} with '${value}' in ${SERVER_PROPERTIES}" + echo "${prop}=${value}" >> "$SERVER_PROPERTIES" + fi +} + function setServerProp { local prop=$1 - local var=$2 - if [ -n "$var" ]; then - # normalize booleans - case ${var^^} in - TRUE|FALSE) - var=${var,,} ;; - esac - if grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then - log "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}" - sed -i "/^${prop}\s*=/ c ${prop}=${var//\\/\\\\}" "$SERVER_PROPERTIES" - else - log "Adding ${prop} with '${var}' in ${SERVER_PROPERTIES}" - echo "${prop}=${var}" >> "$SERVER_PROPERTIES" - fi - else - isDebugging && log "Skip setting ${prop}" + local varName=$2 + + if [ -v $varName ]; then + setServerPropValue "$prop" "${!varName}" fi } function customizeServerProps { - if [ -n "$WHITELIST" ] || isTrue ${ENABLE_WHITELIST:-false}; then + if [ -n "$WHITELIST" ] || isTrue "${ENABLE_WHITELIST:-false}"; then log "Creating whitelist" - setServerProp "whitelist" "true" - setServerProp "white-list" "true" + setServerPropValue "whitelist" "true" + setServerPropValue "white-list" "true" else log "Disabling whitelist" - setServerProp "whitelist" "false" - setServerProp "white-list" "false" + setServerPropValue "whitelist" "false" + setServerPropValue "white-list" "false" fi # If not provided, generate a reasonable default message-of-the-day, @@ -53,57 +59,57 @@ function customizeServerProps { MOTD="A ${label} Minecraft Server powered by Docker" fi - setServerProp "server-name" "$SERVER_NAME" - setServerProp "server-ip" "$SERVER_IP" - setServerProp "server-port" "$SERVER_PORT" - setServerProp "motd" "$(echo $MOTD | mc-image-helper asciify)" - 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" - setServerProp "spawn-protection" "$SPAWN_PROTECTION" - setServerProp "generate-structures" "$GENERATE_STRUCTURES" - setServerProp "view-distance" "$VIEW_DISTANCE" - setServerProp "hardcore" "$HARDCORE" - setServerProp "snooper-enabled" "$SNOOPER_ENABLED" - setServerProp "max-build-height" "$MAX_BUILD_HEIGHT" - setServerProp "force-gamemode" "$FORCE_GAMEMODE" - setServerProp "max-tick-time" "$MAX_TICK_TIME" - 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" - setServerProp "allow-flight" "$ALLOW_FLIGHT" - setServerProp "level-type" "${LEVEL_TYPE^^}" - setServerProp "resource-pack" "$RESOURCE_PACK" - setServerProp "resource-pack-sha1" "$RESOURCE_PACK_SHA1" - setServerProp "player-idle-timeout" "$PLAYER_IDLE_TIMEOUT" - 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" - setServerProp "simulation-distance" "$SIMULATION_DISTANCE" + setServerProp "server-name" SERVER_NAME + setServerProp "server-ip" SERVER_IP + setServerProp "server-port" SERVER_PORT + 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 + setServerProp "spawn-protection" SPAWN_PROTECTION + setServerProp "generate-structures" GENERATE_STRUCTURES + setServerProp "view-distance" VIEW_DISTANCE + setServerProp "hardcore" HARDCORE + setServerProp "snooper-enabled" SNOOPER_ENABLED + setServerProp "max-build-height" MAX_BUILD_HEIGHT + setServerProp "force-gamemode" FORCE_GAMEMODE + setServerProp "max-tick-time" MAX_TICK_TIME + 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 + setServerProp "allow-flight" ALLOW_FLIGHT + setServerProp "resource-pack" RESOURCE_PACK + setServerProp "resource-pack-sha1" RESOURCE_PACK_SHA1 + setServerProp "player-idle-timeout" PLAYER_IDLE_TIMEOUT + 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 + setServerProp "simulation-distance" SIMULATION_DISTANCE + setServerPropValue "motd" "$(echo "$MOTD" | mc-image-helper asciify)" + [[ $LEVEL_TYPE ]] && setServerPropValue "level-type" "${LEVEL_TYPE^^}" if [ -n "$DIFFICULTY" ]; then - case $DIFFICULTY in + case ${DIFFICULTY,,} in peaceful|0) if versionLessThan 1.13; then DIFFICULTY=0 @@ -137,13 +143,12 @@ function customizeServerProps { exit 1 ;; esac - setServerProp "difficulty" "$DIFFICULTY" + setServerPropValue "difficulty" "$DIFFICULTY" fi if [ -n "$MODE" ]; then log "Setting mode" - MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' ) - case $MODE_LC in + case ${MODE,,} in su*|0) if versionLessThan 1.13; then MODE=0 @@ -177,7 +182,7 @@ function customizeServerProps { exit 1 ;; esac - setServerProp "gamemode" "$MODE" + setServerPropValue "gamemode" "$MODE" fi } @@ -210,7 +215,7 @@ fi 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 + 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+)." diff --git a/scripts/start-setupWorld b/scripts/start-setupWorld index dee5055b..d2803f7c 100755 --- a/scripts/start-setupWorld +++ b/scripts/start-setupWorld @@ -1,16 +1,14 @@ #!/bin/bash -. ${SCRIPTS:-/}start-utils +# shellcheck source=start-utils +. "${SCRIPTS:-/}start-utils" set -e isDebugging && set -x -: ${LEVEL:=world} -export LEVEL - if [ $TYPE = "CURSEFORGE" ]; then - worldDest=$FTB_DIR/$LEVEL + worldDest=$FTB_DIR/${LEVEL:-world} else - worldDest=/data/$LEVEL + worldDest=/data/${LEVEL:-world} fi if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] ); then @@ -71,4 +69,4 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] ); fi fi -exec ${SCRIPTS:-/}start-setupModpack $@ +exec "${SCRIPTS:-/}start-setupModpack" "$@"