From f49d09045b68108c6d79c03b63e479a8a437cad1 Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Wed, 1 Jan 2025 12:58:07 -0700 Subject: [PATCH 1/9] Reworking the Paperclip download to work with their new API endpoint. This includes cleaning up the version extraction from the JSON response by using jq. Adding jq to the Dockerfiles to support this. Also adding vim to the Dockerfiles so that users have a choice between nano and vim. --- amd64.Dockerfile | 2 +- arm64v8.Dockerfile | 2 +- armv7.Dockerfile | 2 +- ppc64le.Dockerfile | 2 +- riscv64.Dockerfile | 2 +- s390x.Dockerfile | 2 +- start.sh | 27 +++++++++++++++++++++------ 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/amd64.Dockerfile b/amd64.Dockerfile index 7b802d5..8dc5106 100644 --- a/amd64.Dockerfile +++ b/amd64.Dockerfile @@ -12,7 +12,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install qemu-user-s FROM --platform=linux/amd64 ubuntu:rolling # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano -yqq && rm -rf /var/cache/apt/* +RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/arm64v8.Dockerfile b/arm64v8.Dockerfile index c5bffd5..f551783 100644 --- a/arm64v8.Dockerfile +++ b/arm64v8.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/arm64/v8 ubuntu:rolling COPY --from=builder /usr/bin/qemu-aarch64-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano -yqq && rm -rf /var/cache/apt/* +RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/armv7.Dockerfile b/armv7.Dockerfile index 4893c50..2d19680 100644 --- a/armv7.Dockerfile +++ b/armv7.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/arm/v7 ubuntu:rolling COPY --from=builder /usr/bin/qemu-arm-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4t64 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano -yqq && rm -rf /var/cache/apt/* +RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4t64 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/ppc64le.Dockerfile b/ppc64le.Dockerfile index dbedb94..9eb08a8 100644 --- a/ppc64le.Dockerfile +++ b/ppc64le.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/ppc64le ubuntu:rolling COPY --from=builder /usr/bin/qemu-ppc64le-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano -yqq && rm -rf /var/cache/apt/* +RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/riscv64.Dockerfile b/riscv64.Dockerfile index ab87dd3..426b947 100644 --- a/riscv64.Dockerfile +++ b/riscv64.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/riscv64 ubuntu:rolling COPY --from=builder /usr/bin/qemu-riscv64-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano -yqq && rm -rf /var/cache/apt/* +RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/s390x.Dockerfile b/s390x.Dockerfile index cea20ce..a227dda 100644 --- a/s390x.Dockerfile +++ b/s390x.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/s390x ubuntu:rolling COPY --from=builder /usr/bin/qemu-s390x-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano -yqq && rm -rf /var/cache/apt/* +RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/start.sh b/start.sh index 835ec33..d3ec1ae 100755 --- a/start.sh +++ b/start.sh @@ -154,18 +154,33 @@ if [ "$?" != 0 ]; then echo "Unable to connect to update website (internet connection may be down). Skipping update ..." else # Get latest build - BuildJSON=$(curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" https://papermc.io/api/v2/projects/paper/versions/$Version) - Build=$(echo "$BuildJSON" | rev | cut -d, -f 1 | cut -d']' -f 2 | cut -d'[' -f 1 | rev) + BuildJSON=$(curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" https://api.papermc.io/v2/projects/paper/versions/$Version/builds) + Build=$(echo "$BuildJSON" | jq '.builds | map(select(.channel == "default") | .build) | .[-1]') Build=$(($Build + 0)) if [[ $Build != 0 ]]; then - echo "Latest paperclip build found: $Build" + echo "Latest paperclip build found: $Build (stable)" if [ -z "$QuietCurl" ]; then - curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://papermc.io/api/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" + curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" else - curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://papermc.io/api/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" + curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" fi else - echo "Unable to retrieve latest Paper build (got result of $Build)" + echo "Unable to retrieve latest Paper build (got result of $Build). Retrying the experimental channel for version $Version" + + # Try getting the latest experimental build if no stable build was found + BuildJSON=$(curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" https://api.papermc.io/v2/projects/paper/versions/$Version/builds) + Build=$(echo "$BuildJSON" | jq '.builds | map(select(.channel == "experimental") | .build) | .[-1]') + Build=$(($Build + 0)) + if [[ $Build != 0 ]]; then + echo "Latest paperclip build found: $Build (experimental)" + if [ -z "$QuietCurl" ]; then + curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" + else + curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" + fi + else + echo "Unable to retrieve latest Paper build (got result of $Build)." + fi fi # Update Floodgate From 245c00c486661c0660160bb9fc304b3cc17479c5 Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:55:42 -0700 Subject: [PATCH 2/9] Dockerfiles: setting up the minecraft user, setting the WORKDIR to /minecraft, the USER to minecraft, changing apt to apt-get, and removing unused build stage from the amd64 Dockerfile; shart.sh - lots and lots of changes to streamline some logic (e.g. around QuietCurl), fix bash linting warnings, logging tweaks, consolidating common curl args, suppressing verbose file output for backups, other miscellaneous tweaks --- amd64.Dockerfile | 19 +++-- arm64v8.Dockerfile | 2 +- armv7.Dockerfile | 2 +- ppc64le.Dockerfile | 2 +- riscv64.Dockerfile | 2 +- s390x.Dockerfile | 2 +- start.sh | 185 +++++++++++++++++++++++---------------------- 7 files changed, 111 insertions(+), 103 deletions(-) diff --git a/amd64.Dockerfile b/amd64.Dockerfile index 8dc5106..97c9974 100644 --- a/amd64.Dockerfile +++ b/amd64.Dockerfile @@ -2,17 +2,11 @@ # Author: James A. Chambers - https://jamesachambers.com/minecraft-java-bedrock-server-together-geyser-floodgate/ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate -# Use Ubuntu rolling version for builder -FROM ubuntu:rolling AS builder - -# Update apt -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install qemu-user-static binfmt-support apt-utils -yqq && rm -rf /var/cache/apt/* - # Use Ubuntu rolling version FROM --platform=linux/amd64 ubuntu:rolling # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 @@ -49,12 +43,21 @@ EXPOSE 25565/tcp EXPOSE 19132/tcp EXPOSE 19132/udp -# Copy scripts to minecraftbe folder and make them executable +# Copy files into image and make the scripts executable RUN mkdir /scripts COPY *.sh /scripts/ COPY *.yml /scripts/ COPY server.properties /scripts/ RUN chmod -R +x /scripts/*.sh +# Create the minecraft user/group and set the container to run as the minecraft user +RUN groupadd -g 999 minecraft && \ + useradd -m -u 999 -g 999 -s /bin/bash minecraft && \ + mkdir /minecraft && \ + chown minecraft:minecraft /minecraft && \ + chmod 777 /minecraft +USER minecraft +WORKDIR /minecraft + # Set entrypoint to start.sh script ENTRYPOINT ["/bin/bash", "/scripts/start.sh"] diff --git a/arm64v8.Dockerfile b/arm64v8.Dockerfile index f551783..c055cc6 100644 --- a/arm64v8.Dockerfile +++ b/arm64v8.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/arm64/v8 ubuntu:rolling COPY --from=builder /usr/bin/qemu-aarch64-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/armv7.Dockerfile b/armv7.Dockerfile index 2d19680..349bdf6 100644 --- a/armv7.Dockerfile +++ b/armv7.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/arm/v7 ubuntu:rolling COPY --from=builder /usr/bin/qemu-arm-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4t64 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4t64 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/ppc64le.Dockerfile b/ppc64le.Dockerfile index 9eb08a8..b7e37d3 100644 --- a/ppc64le.Dockerfile +++ b/ppc64le.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/ppc64le ubuntu:rolling COPY --from=builder /usr/bin/qemu-ppc64le-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/riscv64.Dockerfile b/riscv64.Dockerfile index 426b947..fe247e9 100644 --- a/riscv64.Dockerfile +++ b/riscv64.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/riscv64 ubuntu:rolling COPY --from=builder /usr/bin/qemu-riscv64-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/s390x.Dockerfile b/s390x.Dockerfile index a227dda..68146ab 100644 --- a/s390x.Dockerfile +++ b/s390x.Dockerfile @@ -15,7 +15,7 @@ FROM --platform=linux/s390x ubuntu:rolling COPY --from=builder /usr/bin/qemu-s390x-static /usr/bin/ # Fetch dependencies -RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 diff --git a/start.sh b/start.sh index d3ec1ae..812f58c 100755 --- a/start.sh +++ b/start.sh @@ -3,37 +3,39 @@ # Author: James A. Chambers - https://jamesachambers.com/minecraft-java-bedrock-server-together-geyser-floodgate/ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate -# If running as root, create 'minecraft' user and restart script as 'minecraft' user -if [ "$(id -u)" = '0' ]; then - echo "Script is running as root, switching to 'minecraft' user..." +CurlArgs=(-H "Accept-Encoding: identity" + -H "Accept-Language: en" + -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" + -L +) - if ! id minecraft >/dev/null 2>&1; then - echo "Creating 'minecraft' user..." - useradd -m -r -s /bin/bash minecraft - fi +# If running as root, fix ownership of all files and restart script as 'minecraft' user +if [ "$(id -u)" = '0' ]; then + echo "Script is running as '$(whoami)', switching to 'minecraft' user ..." + printf "\tChanging ownership of all files in /minecraft to minecraft:minecraft" chown -R minecraft:minecraft /minecraft - exec su minecraft -c "$0 $@" + printf "\tRestarting script as 'minecraft' user\n" + exec su minecraft -c "$0" "$@" fi echo "Paper Minecraft Java Server Docker + Geyser/Floodgate script by James A. Chambers" echo "Latest version always at https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate" echo "Don't forget to set up port forwarding on your router! The default port is 25565 and the Bedrock port is 19132" -if [ ! -d '/minecraft' ]; then +if ! df -h | grep -q /minecraft; then echo "ERROR: A named volume was not specified for the minecraft server data. Please create one with: docker volume create yourvolumename" echo "Please pass the new volume to docker like this: docker run -it -v yourvolumename:/minecraft" exit 1 +else + echo "Volume mount found for /minecraft" fi -# Randomizer for user agent -RandNum=$(echo $((1 + $RANDOM % 5000))) - if [ -z "$Port" ]; then Port="25565" fi -echo "Port used: $Port" +echo "Java port used: $Port" if [ -z "$BedrockPort" ]; then Port="19132" @@ -41,7 +43,7 @@ fi echo "Bedrock port used: $BedrockPort" # Change directory to server directory -cd /minecraft +cd /minecraft || exit # Create backups/downloads folder if it doesn't exist if [ ! -d "/minecraft/downloads" ]; then @@ -79,48 +81,56 @@ while [ -z "$DefaultRoute" ]; do fi done -# Take ownership of server files and set correct permissions +# Check ownership of server files if [ -z "$NoPermCheck" ]; then - echo "Taking ownership of all server files/folders in /minecraft..." - sudo -n chown -R $(whoami) /minecraft >/dev/null 2>&1 - echo "Complete" + echo "Checking ownership of all server files/folders in /minecraft for user:group - '$(whoami):$(whoami)'" + chown -R minecraft:minecraft /minecraft >/dev/null + printf "\tOwnership check complete. Any errors above could indicate an issue." else - echo "Skipping permissions check due to NoPermCheck flag" + echo "Skipping ownership check due to NoPermCheck flag" fi # Back up server if [ -d "world" ]; then + echo "Running backup ..." + if [ -z "$NoBackup" ]; then + NoBackup="" + else + printf '\tExcluding the following from backups: %s' "${NoBackup}" + fi if [ -n "$(which pigz)" ]; then - echo "Backing up server (all cores) to cd minecraft/backups folder" + printf "\tBacking up server (all cores) to /minecraft/backups folder ..." tarArgs=(-I pigz --exclude='./backups' --exclude='./cache' --exclude='./logs' --exclude='./paperclip.jar') IFS=',' read -ra ADDR <<< "$NoBackup" for i in "${ADDR[@]}"; do tarArgs+=(--exclude="./$i") done - tarArgs+=(-pvcf backups/$(date +%Y.%m.%d.%H.%M.%S).tar.gz ./*) + tarArgs+=(--totals --checkpoint=10000 --checkpoint-action=echo=" #%u: %{r,w}T" -pcf backups/"$(date +%Y.%m.%d.%H.%M.%S)".tar.gz ./*) tar "${tarArgs[@]}" else - echo "Backing up server (single core, pigz not found) to cd minecraft/backups folder" + printf "\tBacking up server (single core, pigz not found) to /minecraft/backups folder ..." tarArgs=(--exclude='./backups' --exclude='./cache' --exclude='./logs' --exclude='./paperclip.jar') IFS=',' read -ra ADDR <<< "$NoBackup" for i in "${ADDR[@]}"; do tarArgs+=(--exclude="./$i") done - tarArgs+=(-pvcf backups/$(date +%Y.%m.%d.%H.%M.%S).tar.gz ./*) + tarArgs+=(--totals --checkpoint=10000 --checkpoint-action=echo=" #%u: %{r,w}T" -pcf backups/"$(date +%Y.%m.%d.%H.%M.%S)".tar.gz ./*) tar "${tarArgs[@]}" fi fi # Rotate backups -if [ -d /minecraft/backups ]; then - Rotate=$( - pushd /minecraft/backups - ls -1tr | head -n -$BackupCount | xargs -d '\n' rm -f -- - popd +if [ -d /minecraft/backups ] && [ -z "$BackupCount" ]; then + ( + pushd /minecraft/backups || exit + find . -type f -printf "%T@ %p\n" | sort -n | head -n -"$BackupCount" | cut -d' ' -f2- | xargs -d '\n' rm -f -- + popd || exit ) fi +# Ensure we are back in the server directory +cd /minecraft || exit # Copy config files if this is a brand new server if [ ! -e "/minecraft/bukkit.yml" ]; then @@ -139,82 +149,75 @@ if [ ! -e "/minecraft/plugins/Geyser-Spigot/config.yml" ]; then cp /scripts/config.yml /minecraft/plugins/Geyser-Spigot/config.yml fi -# Test internet connectivity first # Update paperclip.jar echo "Updating to most recent paperclip version ..." -# Test internet connectivity first -if [ -z "$QuietCurl" ]; then - curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -s https://papermc.io -o /dev/null +# Test update website connectivity first +if ! curl "${CurlArgs[@]}" \ + -s \ + https://api.papermc.io \ + -o /dev/null; then + printf "\tERROR: Unable to connect to update website (internet connection may be down). Skipping server and plugin updates." else - curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -s https://papermc.io -o /dev/null -fi + # Get latest build number + BuildJSON=$(curl --no-progress-meter \ + "${CurlArgs[@]}" \ + https://api.papermc.io/v2/projects/paper/versions/"${Version:?}"/builds + ) + Build=$(echo "$BuildJSON" | jq '.builds | if map(select(.channel == "default")) | length > 0 then map(select(.channel == "default") | .build) | . else map(select(.channel == "experimental") | .build) | . end | .[-1]') + Build=$((Build + 0)) -if [ "$?" != 0 ]; then - echo "Unable to connect to update website (internet connection may be down). Skipping update ..." -else - # Get latest build - BuildJSON=$(curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" https://api.papermc.io/v2/projects/paper/versions/$Version/builds) - Build=$(echo "$BuildJSON" | jq '.builds | map(select(.channel == "default") | .build) | .[-1]') - Build=$(($Build + 0)) + # Download latest build for the targeted version if [[ $Build != 0 ]]; then - echo "Latest paperclip build found: $Build (stable)" - if [ -z "$QuietCurl" ]; then - curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" - else - curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" - fi + printf "\tFound latest paperclip build %s for version %s" "$Build" "$Version" + curl ${QuietCurl:+"--no-progress-meter"} \ + "${CurlArgs[@]}" \ + -o /minecraft/paperclip.jar \ + "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" else - echo "Unable to retrieve latest Paper build (got result of $Build). Retrying the experimental channel for version $Version" - - # Try getting the latest experimental build if no stable build was found - BuildJSON=$(curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" https://api.papermc.io/v2/projects/paper/versions/$Version/builds) - Build=$(echo "$BuildJSON" | jq '.builds | map(select(.channel == "experimental") | .build) | .[-1]') - Build=$(($Build + 0)) - if [[ $Build != 0 ]]; then - echo "Latest paperclip build found: $Build (experimental)" - if [ -z "$QuietCurl" ]; then - curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" - else - curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/paperclip.jar "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" - fi - else - echo "Unable to retrieve latest Paper build (got result of $Build)." - fi + printf "\tUnable to retrieve latest Paper build (got result of: %s)" "$Build" fi # Update Floodgate - echo "Updating Floodgate..." - if [ -z "$QuietCurl" ]; then - curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/Floodgate-Spigot.jar "https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot" - else - curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/Floodgate-Spigot.jar "https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot" - fi + echo "Updating Floodgate ..." + curl ${QuietCurl:+"--no-progress-meter"} \ + "${CurlArgs[@]}" \ + -o /minecraft/plugins/Floodgate-Spigot.jar \ + "https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot" # Update Geyser - echo "Updating Geyser..." - if [ -z "$QuietCurl" ]; then - curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/Geyser-Spigot.jar "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot" - else - curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/Geyser-Spigot.jar "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot" - fi + echo "Updating Geyser ..." + curl ${QuietCurl:+"--no-progress-meter"} \ + "${CurlArgs[@]}" \ + -o /minecraft/plugins/Geyser-Spigot.jar \ + "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot" if [ -z "$NoViaVersion" ]; then # Update ViaVersion if new version is available - ViaVersionVersion=$(curl --no-progress-meter -k -L -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/ | grep -P '(?<=href=")ViaVersion[^"]+' -o --max-count=1 | head -n1) - if [ -n "$ViaVersionVersion" ]; then - ViaVersionMD5=$(curl --no-progress-meter -k -L -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/$ViaVersionVersion/*fingerprint*/" | grep breadcrumbs | cut -d'_' -f24- | cut -d'<' -f2 | cut -d'>' -f2) - if [ -n "$ViaVersionMD5" ]; then - LocalMD5=$(md5sum plugins/ViaVersion.jar | cut -d' ' -f1) - if [ -e /minecraft/plugins/ViaVersion.jar ] && [ "$LocalMD5" = "$ViaVersionMD5" ]; then + ViaVersionLatestVersion=$(curl --no-progress-meter \ + "${CurlArgs[@]}" \ + -k \ + https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/ \ + | grep -P '(?<=href=")ViaVersion[^"]+' -o --max-count=1 | head -n1 + ) + if [ -n "$ViaVersionLatestVersion" ]; then + ViaVersionLatestMD5=$(curl --no-progress-meter \ + "${CurlArgs[@]}" \ + -k \ + "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/$ViaVersionLatestVersion/*fingerprint*/" \ + | grep breadcrumbs | cut -d'_' -f24- | cut -d'<' -f2 | cut -d'>' -f2 + ) + if [ -n "$ViaVersionLatestMD5" ]; then + ViaVersionLocalMD5=$(md5sum plugins/ViaVersion.jar | cut -d' ' -f1) + if [ -e /minecraft/plugins/ViaVersion.jar ] && [ "$ViaVersionLocalMD5" = "$ViaVersionLatestMD5" ]; then echo "ViaVersion is up to date" else - echo "Updating ViaVersion..." - if [ -z "$QuietCurl" ]; then - curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/ViaVersion.jar "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/$ViaVersionVersion" - else - curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" -o /minecraft/plugins/ViaVersion.jar "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/$ViaVersionVersion" - fi + echo "Updating ViaVersion ..." + curl ${QuietCurl:+"--no-progress-meter"} \ + "${CurlArgs[@]}" \ + -k \ + -o /minecraft/plugins/ViaVersion.jar \ + "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/$ViaVersionLatestVersion" fi else echo "Unable to check for updates to ViaVersion!" @@ -226,9 +229,11 @@ else fi # Accept EULA -AcceptEULA=$(echo eula=true >eula.txt) +echo "Accepting EULA" +echo eula=true > eula.txt # Change ports in server.properties +echo "Setting server ports ..." sed -i "/server-port=/c\server-port=$Port" /minecraft/server.properties sed -i "/query\.port=/c\query\.port=$Port" /minecraft/server.properties # Change Bedrock port in Geyser config @@ -237,12 +242,12 @@ if [ -e /minecraft/plugins/Geyser-Spigot/config.yml ]; then fi # Start server -echo "Starting Minecraft server..." +echo "Starting Minecraft server ..." if [[ -z "$MaxMemory" ]] || [[ "$MaxMemory" -le 0 ]]; then exec java -XX:+UnlockDiagnosticVMOptions -XX:-UseAESCTRIntrinsics -DPaper.IgnoreJavaVersion=true -Xms400M -jar /minecraft/paperclip.jar else - exec java -XX:+UnlockDiagnosticVMOptions -XX:-UseAESCTRIntrinsics -DPaper.IgnoreJavaVersion=true -Xms400M -Xmx${MaxMemory}M -jar /minecraft/paperclip.jar + exec java -XX:+UnlockDiagnosticVMOptions -XX:-UseAESCTRIntrinsics -DPaper.IgnoreJavaVersion=true -Xms400M -Xmx"${MaxMemory}"M -jar /minecraft/paperclip.jar fi # Exit container From d8ddc40e0b62381b57a32de4753d2ed508804920 Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:32:28 -0700 Subject: [PATCH 3/9] Dockerfiles: adding --platform to the builder stages for consistency, removed sudo from the install list since we are now running as the minecraft user (which cannot sudo, that's kind of the point), alphabetizing the apt-get install lists to make auditing/checking easier, breaking the long apt-get installs into one package per line to make auditing/checking much easier, making MaxMemory= instead of just = is explicit and makes IDEs happier (plus bash doesn't have variable types, so it isn't like this was an int and now is a string), adding new minecraft user changes to all Dockerfiles --- amd64.Dockerfile | 25 ++++++++++++++++++++++-- arm64v8.Dockerfile | 44 ++++++++++++++++++++++++++++++++++++------ armv7.Dockerfile | 44 ++++++++++++++++++++++++++++++++++++------ ppc64le.Dockerfile | 46 +++++++++++++++++++++++++++++++++++++------- riscv64.Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++-------- s390x.Dockerfile | 44 ++++++++++++++++++++++++++++++++++++------ 6 files changed, 216 insertions(+), 35 deletions(-) diff --git a/amd64.Dockerfile b/amd64.Dockerfile index 97c9974..3900241 100644 --- a/amd64.Dockerfile +++ b/amd64.Dockerfile @@ -6,7 +6,28 @@ FROM --platform=linux/amd64 ubuntu:rolling # Fetch dependencies -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq \ + apt-utils \ + binfmt-support \ + ca-certificates \ + curl \ + gawk \ + findutils \ + jq \ + libcurl4 \ + libcurl4-openssl-dev \ + libc6 \ + libcrypt1 \ + net-tools \ + nano \ + openjdk-21-jre-headless \ + openssl \ + pigz \ + tzdata \ + unzip \ + vim && \ + rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 @@ -15,7 +36,7 @@ ENV Port=25565 ENV BedrockPort=19132 # Optional maximum memory Minecraft is allowed to use -ENV MaxMemory= +ENV MaxMemory="" # Optional Paper Minecraft Version override ENV Version="1.21.3" diff --git a/arm64v8.Dockerfile b/arm64v8.Dockerfile index c055cc6..6041dfc 100644 --- a/arm64v8.Dockerfile +++ b/arm64v8.Dockerfile @@ -3,10 +3,12 @@ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate # Use Ubuntu rolling version for builder -FROM ubuntu:rolling AS builder +FROM --platform=linux/arm64/v8 ubuntu:rolling AS builder -# Update apt -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install qemu-user-static binfmt-support apt-utils -yqq && rm -rf /var/cache/apt/* +# Prep qemu files +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq apt-utils binfmt-support qemu-user-static && \ + rm -rf /var/cache/apt/* # Use Ubuntu rolling version FROM --platform=linux/arm64/v8 ubuntu:rolling @@ -15,7 +17,28 @@ FROM --platform=linux/arm64/v8 ubuntu:rolling COPY --from=builder /usr/bin/qemu-aarch64-static /usr/bin/ # Fetch dependencies -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq \ + apt-utils \ + binfmt-support \ + ca-certificates \ + curl \ + gawk \ + findutils \ + jq \ + libcurl4 \ + libcurl4-openssl-dev \ + libc6 \ + libcrypt1 \ + net-tools \ + nano \ + openjdk-21-jre-headless \ + openssl \ + pigz \ + tzdata \ + unzip \ + vim && \ + rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 @@ -24,7 +47,7 @@ ENV Port=25565 ENV BedrockPort=19132 # Optional maximum memory Minecraft is allowed to use -ENV MaxMemory= +ENV MaxMemory="" # Optional Paper Minecraft Version override ENV Version="1.21.3" @@ -52,12 +75,21 @@ EXPOSE 25565/tcp EXPOSE 19132/tcp EXPOSE 19132/udp -# Copy scripts to minecraftbe folder and make them executable +# Copy files into image and make the scripts executable RUN mkdir /scripts COPY *.sh /scripts/ COPY *.yml /scripts/ COPY server.properties /scripts/ RUN chmod -R +x /scripts/*.sh +# Create the minecraft user/group and set the container to run as the minecraft user +RUN groupadd -g 999 minecraft && \ + useradd -m -u 999 -g 999 -s /bin/bash minecraft && \ + mkdir /minecraft && \ + chown minecraft:minecraft /minecraft && \ + chmod 777 /minecraft +USER minecraft +WORKDIR /minecraft + # Set entrypoint to start.sh script ENTRYPOINT ["/bin/bash", "/scripts/start.sh"] diff --git a/armv7.Dockerfile b/armv7.Dockerfile index 349bdf6..8882861 100644 --- a/armv7.Dockerfile +++ b/armv7.Dockerfile @@ -3,10 +3,12 @@ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate # Use Ubuntu rolling version for builder -FROM ubuntu:rolling AS builder +FROM --platform=linux/arm/v7 ubuntu:rolling AS builder -# Update apt -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install qemu-user-static binfmt-support apt-utils -yqq && rm -rf /var/cache/apt/* +# Prep qemu files +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq apt-utils binfmt-support qemu-user-static && \ + rm -rf /var/cache/apt/* # Use Ubuntu rolling version FROM --platform=linux/arm/v7 ubuntu:rolling @@ -15,7 +17,28 @@ FROM --platform=linux/arm/v7 ubuntu:rolling COPY --from=builder /usr/bin/qemu-arm-static /usr/bin/ # Fetch dependencies -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4t64 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq \ + apt-utils \ + binfmt-support \ + ca-certificates \ + curl \ + gawk \ + findutils \ + jq \ + libcurl4 \ + libcurl4-openssl-dev \ + libc6 \ + libcrypt1 \ + net-tools \ + nano \ + openjdk-21-jre-headless \ + openssl \ + pigz \ + tzdata \ + unzip \ + vim && \ + rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 @@ -24,7 +47,7 @@ ENV Port=25565 ENV BedrockPort=19132 # Optional maximum memory Minecraft is allowed to use -ENV MaxMemory= +ENV MaxMemory="" # Optional Paper Minecraft Version override ENV Version="1.21.3" @@ -52,12 +75,21 @@ EXPOSE 25565/tcp EXPOSE 19132/tcp EXPOSE 19132/udp -# Copy scripts to minecraftbe folder and make them executable +# Copy files into image and make the scripts executable RUN mkdir /scripts COPY *.sh /scripts/ COPY *.yml /scripts/ COPY server.properties /scripts/ RUN chmod -R +x /scripts/*.sh +# Create the minecraft user/group and set the container to run as the minecraft user +RUN groupadd -g 999 minecraft && \ + useradd -m -u 999 -g 999 -s /bin/bash minecraft && \ + mkdir /minecraft && \ + chown minecraft:minecraft /minecraft && \ + chmod 777 /minecraft +USER minecraft +WORKDIR /minecraft + # Set entrypoint to start.sh script ENTRYPOINT ["/bin/bash", "/scripts/start.sh"] diff --git a/ppc64le.Dockerfile b/ppc64le.Dockerfile index b7e37d3..f46edf5 100644 --- a/ppc64le.Dockerfile +++ b/ppc64le.Dockerfile @@ -2,11 +2,13 @@ # Author: James A. Chambers - https://jamesachambers.com/minecraft-java-bedrock-server-together-geyser-floodgate/ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate -# Use latest Ubuntu version for builder -FROM ubuntu:rolling AS builder +# Use Ubuntu rolling version for builder +FROM --platform=linux/ppc64le ubuntu:rolling AS builder -# Update apt -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install qemu-user-static binfmt-support apt-utils -yqq && rm -rf /var/cache/apt/* +# Prep qemu files +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq apt-utils binfmt-support qemu-user-static && \ + rm -rf /var/cache/apt/* # Use Ubuntu rolling version FROM --platform=linux/ppc64le ubuntu:rolling @@ -15,7 +17,28 @@ FROM --platform=linux/ppc64le ubuntu:rolling COPY --from=builder /usr/bin/qemu-ppc64le-static /usr/bin/ # Fetch dependencies -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq \ + apt-utils \ + binfmt-support \ + ca-certificates \ + curl \ + gawk \ + findutils \ + jq \ + libcurl4 \ + libcurl4-openssl-dev \ + libc6 \ + libcrypt1 \ + net-tools \ + nano \ + openjdk-21-jre-headless \ + openssl \ + pigz \ + tzdata \ + unzip \ + vim && \ + rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 @@ -24,7 +47,7 @@ ENV Port=25565 ENV BedrockPort=19132 # Optional maximum memory Minecraft is allowed to use -ENV MaxMemory= +ENV MaxMemory="" # Optional Paper Minecraft Version override ENV Version="1.21.3" @@ -52,12 +75,21 @@ EXPOSE 25565/tcp EXPOSE 19132/tcp EXPOSE 19132/udp -# Copy scripts to minecraftbe folder and make them executable +# Copy files into image and make the scripts executable RUN mkdir /scripts COPY *.sh /scripts/ COPY *.yml /scripts/ COPY server.properties /scripts/ RUN chmod -R +x /scripts/*.sh +# Create the minecraft user/group and set the container to run as the minecraft user +RUN groupadd -g 999 minecraft && \ + useradd -m -u 999 -g 999 -s /bin/bash minecraft && \ + mkdir /minecraft && \ + chown minecraft:minecraft /minecraft && \ + chmod 777 /minecraft +USER minecraft +WORKDIR /minecraft + # Set entrypoint to start.sh script ENTRYPOINT ["/bin/bash", "/scripts/start.sh"] diff --git a/riscv64.Dockerfile b/riscv64.Dockerfile index fe247e9..2fb8b1a 100644 --- a/riscv64.Dockerfile +++ b/riscv64.Dockerfile @@ -2,20 +2,43 @@ # Author: James A. Chambers - https://jamesachambers.com/minecraft-java-bedrock-server-together-geyser-floodgate/ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate -# Use latest Ubuntu version for builder -FROM ubuntu:rolling AS builder +# Use Ubuntu rolling version for builder +FROM --platform=linux/riscv64 ubuntu:rolling AS builder -# Update apt -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install qemu-user-static binfmt-support apt-utils -yqq && rm -rf /var/cache/apt/* +# Prep qemu files +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq apt-utils binfmt-support qemu-user-static && \ + rm -rf /var/cache/apt/* -# Use current Ubuntu LTS version +# Use Ubuntu rolling version FROM --platform=linux/riscv64 ubuntu:rolling # Add QEMU COPY --from=builder /usr/bin/qemu-riscv64-static /usr/bin/ # Fetch dependencies -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq \ + apt-utils \ + binfmt-support \ + ca-certificates \ + curl \ + gawk \ + findutils \ + jq \ + libcurl4 \ + libcurl4-openssl-dev \ + libc6 \ + libcrypt1 \ + net-tools \ + nano \ + openjdk-21-jre-headless \ + openssl \ + pigz \ + tzdata \ + unzip \ + vim && \ + rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 @@ -24,7 +47,7 @@ ENV Port=25565 ENV BedrockPort=19132 # Optional maximum memory Minecraft is allowed to use -ENV MaxMemory= +ENV MaxMemory="" # Optional Paper Minecraft Version override ENV Version="1.21.3" @@ -52,12 +75,21 @@ EXPOSE 25565/tcp EXPOSE 19132/tcp EXPOSE 19132/udp -# Copy scripts to minecraftbe folder and make them executable +# Copy files into image and make the scripts executable RUN mkdir /scripts COPY *.sh /scripts/ COPY *.yml /scripts/ COPY server.properties /scripts/ RUN chmod -R +x /scripts/*.sh +# Create the minecraft user/group and set the container to run as the minecraft user +RUN groupadd -g 999 minecraft && \ + useradd -m -u 999 -g 999 -s /bin/bash minecraft && \ + mkdir /minecraft && \ + chown minecraft:minecraft /minecraft && \ + chmod 777 /minecraft +USER minecraft +WORKDIR /minecraft + # Set entrypoint to start.sh script ENTRYPOINT ["/bin/bash", "/scripts/start.sh"] diff --git a/s390x.Dockerfile b/s390x.Dockerfile index 68146ab..a928d85 100644 --- a/s390x.Dockerfile +++ b/s390x.Dockerfile @@ -3,10 +3,12 @@ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate # Use Ubuntu rolling version for builder -FROM ubuntu:rolling AS builder +FROM --platform=linux/s390x ubuntu:rolling AS builder -# Update apt -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install qemu-user-static binfmt-support apt-utils -yqq && rm -rf /var/cache/apt/* +# Prep qemu files +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq apt-utils binfmt-support qemu-user-static && \ + rm -rf /var/cache/apt/* # Use Ubuntu rolling version FROM --platform=linux/s390x ubuntu:rolling @@ -15,7 +17,28 @@ FROM --platform=linux/s390x ubuntu:rolling COPY --from=builder /usr/bin/qemu-s390x-static /usr/bin/ # Fetch dependencies -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install openjdk-21-jre-headless tzdata sudo curl unzip net-tools gawk openssl findutils pigz libcurl4 libc6 libcrypt1 apt-utils libcurl4-openssl-dev ca-certificates binfmt-support nano jq vim -yqq && rm -rf /var/cache/apt/* +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yqq \ + apt-utils \ + binfmt-support \ + ca-certificates \ + curl \ + gawk \ + findutils \ + jq \ + libcurl4 \ + libcurl4-openssl-dev \ + libc6 \ + libcrypt1 \ + net-tools \ + nano \ + openjdk-21-jre-headless \ + openssl \ + pigz \ + tzdata \ + unzip \ + vim && \ + rm -rf /var/cache/apt/* # Set port environment variable ENV Port=25565 @@ -24,7 +47,7 @@ ENV Port=25565 ENV BedrockPort=19132 # Optional maximum memory Minecraft is allowed to use -ENV MaxMemory= +ENV MaxMemory="" # Optional Paper Minecraft Version override ENV Version="1.21.3" @@ -52,12 +75,21 @@ EXPOSE 25565/tcp EXPOSE 19132/tcp EXPOSE 19132/udp -# Copy scripts to minecraftbe folder and make them executable +# Copy files into image and make the scripts executable RUN mkdir /scripts COPY *.sh /scripts/ COPY *.yml /scripts/ COPY server.properties /scripts/ RUN chmod -R +x /scripts/*.sh +# Create the minecraft user/group and set the container to run as the minecraft user +RUN groupadd -g 999 minecraft && \ + useradd -m -u 999 -g 999 -s /bin/bash minecraft && \ + mkdir /minecraft && \ + chown minecraft:minecraft /minecraft && \ + chmod 777 /minecraft +USER minecraft +WORKDIR /minecraft + # Set entrypoint to start.sh script ENTRYPOINT ["/bin/bash", "/scripts/start.sh"] From 3251bdc7783ece6dd10cc320da5da79705f592b7 Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Fri, 3 Jan 2025 14:26:12 -0700 Subject: [PATCH 4/9] start.sh: reworking the server backup tar arg generation, reorganizing more things, reverting some logs from printf because they end up delayed flushing to stdout, tweaking some more logs/echos --- start.sh | 92 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/start.sh b/start.sh index 812f58c..d384e72 100755 --- a/start.sh +++ b/start.sh @@ -3,20 +3,21 @@ # Author: James A. Chambers - https://jamesachambers.com/minecraft-java-bedrock-server-together-geyser-floodgate/ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate -CurlArgs=(-H "Accept-Encoding: identity" - -H "Accept-Language: en" - -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" - -L +CurlArgs=( + -H "Accept-Encoding: identity" + -H "Accept-Language: en" + -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" + -L ) # If running as root, fix ownership of all files and restart script as 'minecraft' user if [ "$(id -u)" = '0' ]; then echo "Script is running as '$(whoami)', switching to 'minecraft' user ..." - printf "\tChanging ownership of all files in /minecraft to minecraft:minecraft" - chown -R minecraft:minecraft /minecraft + echo " Changing ownership of all files in /minecraft to 'minecraft:minecraft'" + chown -R minecraft:minecraft /minecraft >/dev/null - printf "\tRestarting script as 'minecraft' user\n" + echo " Restarting script as 'minecraft' user" exec su minecraft -c "$0" "$@" fi @@ -32,16 +33,6 @@ else echo "Volume mount found for /minecraft" fi -if [ -z "$Port" ]; then - Port="25565" -fi -echo "Java port used: $Port" - -if [ -z "$BedrockPort" ]; then - Port="19132" -fi -echo "Bedrock port used: $BedrockPort" - # Change directory to server directory cd /minecraft || exit @@ -60,12 +51,12 @@ if [ ! -d "/minecraft/plugins/Geyser-Spigot" ]; then fi # Check if network interfaces are up -NetworkChecks=0 if [ -e '/sbin/route' ]; then DefaultRoute=$(/sbin/route -n | awk '$4 == "UG" {print $2}') else DefaultRoute=$(route -n | awk '$4 == "UG" {print $2}') fi +NetworkChecks=0 while [ -z "$DefaultRoute" ]; do echo "Network interface not up, will try again in 1 second" sleep 1 @@ -85,7 +76,7 @@ done if [ -z "$NoPermCheck" ]; then echo "Checking ownership of all server files/folders in /minecraft for user:group - '$(whoami):$(whoami)'" chown -R minecraft:minecraft /minecraft >/dev/null - printf "\tOwnership check complete. Any errors above could indicate an issue." + echo " Ownership check complete. Any errors above could indicate an issue." else echo "Skipping ownership check due to NoPermCheck flag" fi @@ -93,32 +84,39 @@ fi # Back up server if [ -d "world" ]; then echo "Running backup ..." - if [ -z "$NoBackup" ]; then - NoBackup="" + # Build tar args + if [ -n "$(which pigz)" ]; then + tarCompression="-I pigz" + coresMsg="all cores" else - printf '\tExcluding the following from backups: %s' "${NoBackup}" + tarCompression="" + coresMsg="single core, pigz not found" fi - if [ -n "$(which pigz)" ]; then - printf "\tBacking up server (all cores) to /minecraft/backups folder ..." - tarArgs=(-I pigz --exclude='./backups' --exclude='./cache' --exclude='./logs' --exclude='./paperclip.jar') - IFS=',' - read -ra ADDR <<< "$NoBackup" - for i in "${ADDR[@]}"; do - tarArgs+=(--exclude="./$i") - done - tarArgs+=(--totals --checkpoint=10000 --checkpoint-action=echo=" #%u: %{r,w}T" -pcf backups/"$(date +%Y.%m.%d.%H.%M.%S)".tar.gz ./*) - tar "${tarArgs[@]}" + echo " Backing up server ($coresMsg) to /minecraft/backups folder..." + tarArgs=( + "$tarCompression" + --exclude='./backups' + --exclude='./cache' + --exclude='./logs' + --exclude='./paperclip.jar' + ) + if [ -z "$NoBackup" ]; then + NoBackup="" else - printf "\tBacking up server (single core, pigz not found) to /minecraft/backups folder ..." - tarArgs=(--exclude='./backups' --exclude='./cache' --exclude='./logs' --exclude='./paperclip.jar') + echo " Excluding the following from backups: ${NoBackup}" IFS=',' read -ra ADDR <<< "$NoBackup" for i in "${ADDR[@]}"; do tarArgs+=(--exclude="./$i") done - tarArgs+=(--totals --checkpoint=10000 --checkpoint-action=echo=" #%u: %{r,w}T" -pcf backups/"$(date +%Y.%m.%d.%H.%M.%S)".tar.gz ./*) - tar "${tarArgs[@]}" fi + tarArgs+=( + --checkpoint=10000 + --checkpoint-action="echo=#%u: %{w}T" + --totals + -pcf "backups/$(date +%Y.%m.%d.%H.%M.%S)".tar.gz + ) + tar "${tarArgs[@]}" 2>&1 | sed 's/^tar: / /' fi # Rotate backups @@ -157,7 +155,7 @@ if ! curl "${CurlArgs[@]}" \ -s \ https://api.papermc.io \ -o /dev/null; then - printf "\tERROR: Unable to connect to update website (internet connection may be down). Skipping server and plugin updates." + echo "ERROR: Unable to connect to update website (internet connection may be down). Skipping server and plugin updates." else # Get latest build number BuildJSON=$(curl --no-progress-meter \ @@ -169,13 +167,13 @@ else # Download latest build for the targeted version if [[ $Build != 0 ]]; then - printf "\tFound latest paperclip build %s for version %s" "$Build" "$Version" + echo " Found latest paperclip build $Build for version $Version" curl ${QuietCurl:+"--no-progress-meter"} \ "${CurlArgs[@]}" \ -o /minecraft/paperclip.jar \ "https://api.papermc.io/v2/projects/paper/versions/$Version/builds/$Build/downloads/paper-$Version-$Build.jar" else - printf "\tUnable to retrieve latest Paper build (got result of: %s)" "$Build" + echo " Unable to retrieve latest Paper build (got result of: $Build)" fi # Update Floodgate @@ -194,6 +192,7 @@ else if [ -z "$NoViaVersion" ]; then # Update ViaVersion if new version is available + echo "Checking the latest version of ViaVersion ..." ViaVersionLatestVersion=$(curl --no-progress-meter \ "${CurlArgs[@]}" \ -k \ @@ -210,9 +209,9 @@ else if [ -n "$ViaVersionLatestMD5" ]; then ViaVersionLocalMD5=$(md5sum plugins/ViaVersion.jar | cut -d' ' -f1) if [ -e /minecraft/plugins/ViaVersion.jar ] && [ "$ViaVersionLocalMD5" = "$ViaVersionLatestMD5" ]; then - echo "ViaVersion is up to date" + echo " ViaVersion is up to date" else - echo "Updating ViaVersion ..." + echo " Updating ViaVersion ..." curl ${QuietCurl:+"--no-progress-meter"} \ "${CurlArgs[@]}" \ -k \ @@ -229,21 +228,28 @@ else fi # Accept EULA -echo "Accepting EULA" +echo "Accepting EULA ..." echo eula=true > eula.txt # Change ports in server.properties echo "Setting server ports ..." +if [ -z "$Port" ]; then + Port="25565" +fi +echo " Java port used: $Port" sed -i "/server-port=/c\server-port=$Port" /minecraft/server.properties sed -i "/query\.port=/c\query\.port=$Port" /minecraft/server.properties # Change Bedrock port in Geyser config +if [ -z "$BedrockPort" ]; then + Port="19132" +fi +echo " Bedrock port used: $BedrockPort" if [ -e /minecraft/plugins/Geyser-Spigot/config.yml ]; then sed -i -z "s/ port: [0-9]*/ port: $BedrockPort/" /minecraft/plugins/Geyser-Spigot/config.yml fi # Start server echo "Starting Minecraft server ..." - if [[ -z "$MaxMemory" ]] || [[ "$MaxMemory" -le 0 ]]; then exec java -XX:+UnlockDiagnosticVMOptions -XX:-UseAESCTRIntrinsics -DPaper.IgnoreJavaVersion=true -Xms400M -jar /minecraft/paperclip.jar else From 0b13652c1bd059d8b2cf11aeb9dd2dd3a4ccfd18 Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Fri, 3 Jan 2025 16:11:07 -0700 Subject: [PATCH 5/9] start.sh: fixing backups and backup rotation; opting to not show any output during backups...it'll just be noisy and clutter the logs (albeit much less than the previous highly verbose backup logging) --- start.sh | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/start.sh b/start.sh index d384e72..612dd59 100755 --- a/start.sh +++ b/start.sh @@ -85,42 +85,40 @@ fi if [ -d "world" ]; then echo "Running backup ..." # Build tar args - if [ -n "$(which pigz)" ]; then - tarCompression="-I pigz" - coresMsg="all cores" - else - tarCompression="" - coresMsg="single core, pigz not found" - fi - echo " Backing up server ($coresMsg) to /minecraft/backups folder..." - tarArgs=( - "$tarCompression" + tarExcludes=( --exclude='./backups' --exclude='./cache' --exclude='./logs' --exclude='./paperclip.jar' ) - if [ -z "$NoBackup" ]; then - NoBackup="" - else - echo " Excluding the following from backups: ${NoBackup}" + if [ -n "$NoBackup" ]; then + echo " Excluding the following extra items from backups: ${NoBackup}" IFS=',' read -ra ADDR <<< "$NoBackup" for i in "${ADDR[@]}"; do - tarArgs+=(--exclude="./$i") + tarExcludes+=(--exclude="./$i") done fi - tarArgs+=( - --checkpoint=10000 - --checkpoint-action="echo=#%u: %{w}T" - --totals - -pcf "backups/$(date +%Y.%m.%d.%H.%M.%S)".tar.gz - ) - tar "${tarArgs[@]}" 2>&1 | sed 's/^tar: / /' + if [ -n "$(which pigz)" ]; then + tarCompression="-I pigz" + coresMsg="all cores" + else + tarCompression="" + coresMsg="single core, pigz not found" + fi + echo " Backing up server ($coresMsg) to /minecraft/backups folder..." + tar "${tarExcludes[@]}" \ + "$tarCompression" \ + --checkpoint=10000 \ + --checkpoint-action="echo=#%u: %{w}T" \ + --totals \ + -pcf \ + "backups/$(date +%Y.%m.%d.%H.%M.%S).tar.gz" \ + . 2>&1 | sed 's/^Total bytes written:/ Total bytes written:/' fi # Rotate backups -if [ -d /minecraft/backups ] && [ -z "$BackupCount" ]; then +if [ -d /minecraft/backups ] && [ -n "$BackupCount" ]; then ( pushd /minecraft/backups || exit find . -type f -printf "%T@ %p\n" | sort -n | head -n -"$BackupCount" | cut -d' ' -f2- | xargs -d '\n' rm -f -- @@ -209,7 +207,7 @@ else if [ -n "$ViaVersionLatestMD5" ]; then ViaVersionLocalMD5=$(md5sum plugins/ViaVersion.jar | cut -d' ' -f1) if [ -e /minecraft/plugins/ViaVersion.jar ] && [ "$ViaVersionLocalMD5" = "$ViaVersionLatestMD5" ]; then - echo " ViaVersion is up to date" + echo " ViaVersion is up to date: $ViaVersionLatestVersion" else echo " Updating ViaVersion ..." curl ${QuietCurl:+"--no-progress-meter"} \ From 802ec1fc63f77bcf14b7a79424e4bc291cc2a595 Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Fri, 3 Jan 2025 20:44:28 -0700 Subject: [PATCH 6/9] start.sh: more logging tweaks and output cleanup --- start.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/start.sh b/start.sh index 612dd59..17735ea 100755 --- a/start.sh +++ b/start.sh @@ -14,16 +14,16 @@ CurlArgs=( if [ "$(id -u)" = '0' ]; then echo "Script is running as '$(whoami)', switching to 'minecraft' user ..." - echo " Changing ownership of all files in /minecraft to 'minecraft:minecraft'" + echo " Changing ownership of all files in /minecraft to 'minecraft:minecraft' ..." chown -R minecraft:minecraft /minecraft >/dev/null - echo " Restarting script as 'minecraft' user" + echo " Restarting script as 'minecraft' user." exec su minecraft -c "$0" "$@" fi echo "Paper Minecraft Java Server Docker + Geyser/Floodgate script by James A. Chambers" echo "Latest version always at https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate" -echo "Don't forget to set up port forwarding on your router! The default port is 25565 and the Bedrock port is 19132" +echo "Don't forget to set up port forwarding on your router! The default port is 25565 and the Bedrock port is 19132." if ! df -h | grep -q /minecraft; then echo "ERROR: A named volume was not specified for the minecraft server data. Please create one with: docker volume create yourvolumename" @@ -51,6 +51,7 @@ if [ ! -d "/minecraft/plugins/Geyser-Spigot" ]; then fi # Check if network interfaces are up +echo "Checking network interface status ..." if [ -e '/sbin/route' ]; then DefaultRoute=$(/sbin/route -n | awk '$4 == "UG" {print $2}') else @@ -58,7 +59,7 @@ else fi NetworkChecks=0 while [ -z "$DefaultRoute" ]; do - echo "Network interface not up, will try again in 1 second" + echo " Network interface not up, will try again in 1 second ..." sleep 1 if [ -e '/sbin/route' ]; then DefaultRoute=$(/sbin/route -n | awk '$4 == "UG" {print $2}') @@ -67,18 +68,21 @@ while [ -z "$DefaultRoute" ]; do fi NetworkChecks=$((NetworkChecks + 1)) if [ $NetworkChecks -gt 20 ]; then - echo "Waiting for network interface to come up timed out - starting server without network connection ..." + echo "ERROR: Waiting for network interface to come up timed out - starting server without network connection." break fi + if [ -n "$DefaultRoute" ]; then + echo " Network interface is up." + fi done # Check ownership of server files if [ -z "$NoPermCheck" ]; then - echo "Checking ownership of all server files/folders in /minecraft for user:group - '$(whoami):$(whoami)'" + echo "Checking ownership of all server files/folders in /minecraft for user:group - '$(whoami):$(whoami)' ..." chown -R minecraft:minecraft /minecraft >/dev/null echo " Ownership check complete. Any errors above could indicate an issue." else - echo "Skipping ownership check due to NoPermCheck flag" + echo "Skipping ownership check due to NoPermCheck flag." fi # Back up server @@ -109,8 +113,6 @@ if [ -d "world" ]; then echo " Backing up server ($coresMsg) to /minecraft/backups folder..." tar "${tarExcludes[@]}" \ "$tarCompression" \ - --checkpoint=10000 \ - --checkpoint-action="echo=#%u: %{w}T" \ --totals \ -pcf \ "backups/$(date +%Y.%m.%d.%H.%M.%S).tar.gz" \ @@ -123,10 +125,10 @@ if [ -d /minecraft/backups ] && [ -n "$BackupCount" ]; then pushd /minecraft/backups || exit find . -type f -printf "%T@ %p\n" | sort -n | head -n -"$BackupCount" | cut -d' ' -f2- | xargs -d '\n' rm -f -- popd || exit - ) + ) > /dev/null fi # Ensure we are back in the server directory -cd /minecraft || exit +cd /minecraft > /dev/null || exit # Copy config files if this is a brand new server if [ ! -e "/minecraft/bukkit.yml" ]; then @@ -247,7 +249,10 @@ if [ -e /minecraft/plugins/Geyser-Spigot/config.yml ]; then fi # Start server +echo "" +echo "************************************************************************" echo "Starting Minecraft server ..." +echo "************************************************************************" if [[ -z "$MaxMemory" ]] || [[ "$MaxMemory" -le 0 ]]; then exec java -XX:+UnlockDiagnosticVMOptions -XX:-UseAESCTRIntrinsics -DPaper.IgnoreJavaVersion=true -Xms400M -jar /minecraft/paperclip.jar else From 70cb80b3e814208997578cba66d4d4857ef5ca40 Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Fri, 3 Jan 2025 22:33:38 -0700 Subject: [PATCH 7/9] start.sh: even more logging tweaking --- start.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/start.sh b/start.sh index 17735ea..725d8be 100755 --- a/start.sh +++ b/start.sh @@ -21,16 +21,23 @@ if [ "$(id -u)" = '0' ]; then exec su minecraft -c "$0" "$@" fi +echo "################################################################################################################" echo "Paper Minecraft Java Server Docker + Geyser/Floodgate script by James A. Chambers" +echo "################################################################################################################" echo "Latest version always at https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate" echo "Don't forget to set up port forwarding on your router! The default port is 25565 and the Bedrock port is 19132." +echo "" +echo "************************************************************************" +echo "Prepare Environment" +echo "************************************************************************" +echo "Checking volume mount ..." if ! df -h | grep -q /minecraft; then echo "ERROR: A named volume was not specified for the minecraft server data. Please create one with: docker volume create yourvolumename" echo "Please pass the new volume to docker like this: docker run -it -v yourvolumename:/minecraft" exit 1 else - echo "Volume mount found for /minecraft" + echo " Volume mount found for /minecraft" fi # Change directory to server directory @@ -148,7 +155,7 @@ if [ ! -e "/minecraft/plugins/Geyser-Spigot/config.yml" ]; then fi # Update paperclip.jar -echo "Updating to most recent paperclip version ..." +echo "Updating to most recent Paper server version ..." # Test update website connectivity first if ! curl "${CurlArgs[@]}" \ @@ -167,7 +174,7 @@ else # Download latest build for the targeted version if [[ $Build != 0 ]]; then - echo " Found latest paperclip build $Build for version $Version" + echo " Found latest Paper build $Build for version $Version" curl ${QuietCurl:+"--no-progress-meter"} \ "${CurlArgs[@]}" \ -o /minecraft/paperclip.jar \ @@ -190,9 +197,10 @@ else -o /minecraft/plugins/Geyser-Spigot.jar \ "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot" + echo "Updating ViaVersion ..." if [ -z "$NoViaVersion" ]; then # Update ViaVersion if new version is available - echo "Checking the latest version of ViaVersion ..." + echo " Checking the latest version of ViaVersion ..." ViaVersionLatestVersion=$(curl --no-progress-meter \ "${CurlArgs[@]}" \ -k \ @@ -211,7 +219,7 @@ else if [ -e /minecraft/plugins/ViaVersion.jar ] && [ "$ViaVersionLocalMD5" = "$ViaVersionLatestMD5" ]; then echo " ViaVersion is up to date: $ViaVersionLatestVersion" else - echo " Updating ViaVersion ..." + echo " Downloading new version: $ViaVersionLatestVersion" curl ${QuietCurl:+"--no-progress-meter"} \ "${CurlArgs[@]}" \ -k \ @@ -219,11 +227,11 @@ else "https://ci.viaversion.com/job/ViaVersion/lastBuild/artifact/build/libs/$ViaVersionLatestVersion" fi else - echo "Unable to check for updates to ViaVersion!" + echo "ERROR: Unable to check for updates to ViaVersion!" fi fi else - echo "ViaVersion is disabled -- skipping" + echo " ViaVersion is disabled -- skipping" fi fi @@ -251,8 +259,9 @@ fi # Start server echo "" echo "************************************************************************" -echo "Starting Minecraft server ..." +echo "Launch Minecraft" echo "************************************************************************" +echo "Starting Minecraft server ..." if [[ -z "$MaxMemory" ]] || [[ "$MaxMemory" -le 0 ]]; then exec java -XX:+UnlockDiagnosticVMOptions -XX:-UseAESCTRIntrinsics -DPaper.IgnoreJavaVersion=true -Xms400M -jar /minecraft/paperclip.jar else From 4225e860cfc446a295b5fd38ab1cac5b7129885b Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Fri, 3 Jan 2025 22:41:15 -0700 Subject: [PATCH 8/9] start.sh: fix network check success log --- start.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/start.sh b/start.sh index 725d8be..c4f40ca 100755 --- a/start.sh +++ b/start.sh @@ -64,6 +64,9 @@ if [ -e '/sbin/route' ]; then else DefaultRoute=$(route -n | awk '$4 == "UG" {print $2}') fi +if [ -n "$DefaultRoute" ]; then + echo " Network interface is up." +fi NetworkChecks=0 while [ -z "$DefaultRoute" ]; do echo " Network interface not up, will try again in 1 second ..." From ad09808391c9b28629c26810363cd2fd3a9dc103 Mon Sep 17 00:00:00 2001 From: cyberops7 <18562612+cyberops7@users.noreply.github.com> Date: Sat, 4 Jan 2025 09:21:12 -0700 Subject: [PATCH 9/9] Dockerfiles: removing the --platform flags from the non-amd64 builder stages to see if that change is what broke the failing tests. --- arm64v8.Dockerfile | 2 +- armv7.Dockerfile | 2 +- ppc64le.Dockerfile | 2 +- riscv64.Dockerfile | 2 +- s390x.Dockerfile | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arm64v8.Dockerfile b/arm64v8.Dockerfile index 6041dfc..fb2b79e 100644 --- a/arm64v8.Dockerfile +++ b/arm64v8.Dockerfile @@ -3,7 +3,7 @@ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate # Use Ubuntu rolling version for builder -FROM --platform=linux/arm64/v8 ubuntu:rolling AS builder +FROM ubuntu:rolling AS builder # Prep qemu files RUN apt-get update && \ diff --git a/armv7.Dockerfile b/armv7.Dockerfile index 8882861..c01a82b 100644 --- a/armv7.Dockerfile +++ b/armv7.Dockerfile @@ -3,7 +3,7 @@ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate # Use Ubuntu rolling version for builder -FROM --platform=linux/arm/v7 ubuntu:rolling AS builder +FROM ubuntu:rolling AS builder # Prep qemu files RUN apt-get update && \ diff --git a/ppc64le.Dockerfile b/ppc64le.Dockerfile index f46edf5..ea8e35c 100644 --- a/ppc64le.Dockerfile +++ b/ppc64le.Dockerfile @@ -3,7 +3,7 @@ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate # Use Ubuntu rolling version for builder -FROM --platform=linux/ppc64le ubuntu:rolling AS builder +FROM ubuntu:rolling AS builder # Prep qemu files RUN apt-get update && \ diff --git a/riscv64.Dockerfile b/riscv64.Dockerfile index 2fb8b1a..9f75ef9 100644 --- a/riscv64.Dockerfile +++ b/riscv64.Dockerfile @@ -3,7 +3,7 @@ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate # Use Ubuntu rolling version for builder -FROM --platform=linux/riscv64 ubuntu:rolling AS builder +FROM ubuntu:rolling AS builder # Prep qemu files RUN apt-get update && \ diff --git a/s390x.Dockerfile b/s390x.Dockerfile index a928d85..a54192c 100644 --- a/s390x.Dockerfile +++ b/s390x.Dockerfile @@ -3,7 +3,7 @@ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate # Use Ubuntu rolling version for builder -FROM --platform=linux/s390x ubuntu:rolling AS builder +FROM ubuntu:rolling AS builder # Prep qemu files RUN apt-get update && \