Files
dockercraft/scripts/lib/common.sh
T
jeremy 5688b30892 fix: migrate PaperMC to v3 API, fix NeoForge beta fallback, add test suite
- Migrate Paper loader from sunset v2 API to v3 (fill.papermc.io)
- Fix NeoForge: fall back to beta versions when no stable exists (set -e + grep)
- Fix setEula/setperms ordering (was writing eula.txt before /data was writable)
- Fix setEula/serverInfoWrite to use absolute paths (/data/server/)
- Add VOLUME directive removal (was shadowing bind mounts)
- Add comprehensive API test suite (110 tests across 6 suites)
- Move test.sh to tests/integration.sh, switch to named volumes
- Add Docker build cache to CI workflows
- Add .editorconfig, expand .gitignore, improve README docs
2026-08-21 12:49:27 -04:00

72 lines
1.5 KiB
Bash

# ---------- helpers --------------------------------------------------------
log() {
echo -e "[dockercraft] $*"
}
warn() {
echo -e "[dockercraft] WARNING: $*" >&2
}
die() {
echo -e "[dockercraft] ERROR: $*" >&2
sleep 2
exit 1
}
crash() {
die "$@"
}
# ---------- permission setup -----------------------------------------------
setperms() {
log "--- Setting permissions to UID:${PUID} GID:${PGID} ---"
sudo usermod -u "${PUID}" minecraft
sudo groupmod -g "${PGID}" minecraft
sudo chown -R "${PUID}:${PGID}" /data
log "Permissions set."
}
# ---------- EULA -----------------------------------------------------------
setEula() {
if [[ "${EULA:-false}" != "true" ]]; then
die "EULA not accepted. Set EULA=true to accept the Minecraft EULA (https://aka.ms/MinecraftEULA)"
fi
mkdir -p /data/server
cat <<'EOF' > /data/server/eula.txt
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
eula=true
EOF
}
# ---------- misc -----------------------------------------------------------
newForge() {
if [[ "$(printf '%s\n' "1.17.1" "$MC_VERSION" | sort -V | head -n1)" = "1.17.1" ]]; then
NEW_FORGE=true
else
NEW_FORGE=false
fi
}
serverInfoWrite() {
cat <<EOF > /data/server/server.info
MC_VERSION=${MC_VERSION}
MC_LOADER=${MC_LOADER}
MC_LOADER_VERSION=${MC_LOADER_VERSION}
JAVA_VERSION=${JAVA_VERSION:-"N/A"}
JAR=${JAR:-"N/A"}
XMS=${XMS:-"N/A"}
XMX=${XMX:-"N/A"}
ADD_ARGS=${ADD_ARGS:-"NONE"}
PUID=${PUID}
PGID=${PGID}
EOF
}