Resolve NeoForge version automatically, default heap to 13G

deploy.sh previously required -N and failed outright without it. It now passes
-N latest by default, and mc-service-setup.sh resolves the newest stable build
in the series matching the Minecraft version from the NeoForged maven
(1.21.1 -> 21.1.x, 1.21 -> 21.0.x), excluding betas. Pin a version with -N to
opt out.

Heap defaults raised to 13G for both Xms and Xmx. README documents capping the
ZFS ARC alongside it, since ARC defaults to half of RAM and would otherwise
contend with a heap this size on the same box.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
main
Amir Alexander Abdelbaki 2026-08-05 22:31:23 +02:00
parent e738422dbe
commit 1f50667d36
3 changed files with 61 additions and 7 deletions

View File

@ -11,9 +11,13 @@ Everything lives on a ZFS dataset mounted at `/minecraft`.
```bash ```bash
./deploy.sh -n "Opengames" -a themiro \ ./deploy.sh -n "Opengames" -a themiro \
-u https://games.abdelbaki.eu/mods \ -u https://games.abdelbaki.eu/mods \
-N 21.1.72 --accept-eula --accept-eula
``` ```
The NeoForge version is resolved automatically — the newest stable build in the
series matching your Minecraft version, from the NeoForged maven. Pin one with
`-N 21.1.248` if you'd rather not track latest.
Then: Then:
```bash ```bash
@ -35,6 +39,23 @@ server address already filled in.
| `mc-refresh-restart.sh` | you | Re-sync the pack after changing mods, then restart | | `mc-refresh-restart.sh` | you | Re-sync the pack after changing mods, then restart |
| `build.sh` | you | Builds the release zip | | `build.sh` | you | Builds the release zip |
## Memory
The heap defaults to 13 GB (`-X`/`-x` to change it). `-XX:+AlwaysPreTouch` means
the JVM commits the whole heap at startup rather than growing into it.
On a ZFS host, cap the ARC before running a heap this large — ZFS defaults to
using up to half of RAM for cache, which will fight the JVM for the same pages:
```bash
echo "options zfs zfs_arc_max=2147483648" | sudo tee /etc/modprobe.d/zfs.conf
sudo dracut --force && sudo reboot
```
That pins the ARC to 2 GB. On a 16 GB box, 13 GB heap + 2 GB ARC leaves ~1 GB
for everything else, which is tight — drop the heap to 1011 GB if the host
does anything besides run the server.
## Requirements ## Requirements
- Fedora (or any systemd distro; `dnf` calls need swapping otherwise) - Fedora (or any systemd distro; `dnf` calls need swapping otherwise)

View File

@ -13,8 +13,8 @@
set -euo pipefail set -euo pipefail
NAME=""; AUTHOR=""; BASEURL=""; NFVER=""; MCVER="1.21.1" NAME=""; AUTHOR=""; BASEURL=""; NFVER="latest"; MCVER="1.21.1"
SHARE="/minecraft"; XMX="8G"; XMS="4G"; ACCEPT_EULA="" SHARE="/minecraft"; XMX="13G"; XMS="13G"; ACCEPT_EULA=""
HERE="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" HERE="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
die() { echo "error: $*" >&2; exit 1; } die() { echo "error: $*" >&2; exit 1; }
@ -51,7 +51,7 @@ sudo -v || die "sudo is required"
step "1/2 Minecraft systemd service" step "1/2 Minecraft systemd service"
sudo "$HERE/mc-service-setup.sh" \ sudo "$HERE/mc-service-setup.sh" \
-s "$SHARE" -A "$USER" -X "$XMX" -x "$XMS" \ -s "$SHARE" -A "$USER" -X "$XMX" -x "$XMS" -m "$MCVER" \
${NFVER:+-N "$NFVER"} ${ACCEPT_EULA} ${NFVER:+-N "$NFVER"} ${ACCEPT_EULA}
step "2/2 packwiz pack and player guides" step "2/2 packwiz pack and player guides"

View File

@ -18,9 +18,10 @@ set -euo pipefail
SHARE="/minecraft" SHARE="/minecraft"
MCUSER="minecraft" MCUSER="minecraft"
XMS="4G" XMS="13G"
XMX="8G" XMX="13G"
NFVER="" # set to install the NeoForge server NFVER="" # version, or "latest" to resolve one; empty = don't install
MCVER="1.21.1" # only used to pick the matching NeoForge series
ADMIN="" # human user who authors the pack on the share ADMIN="" # human user who authors the pack on the share
ACCEPT_EULA=0 ACCEPT_EULA=0
UNIT_DIR="/etc/systemd/system" UNIT_DIR="/etc/systemd/system"
@ -38,6 +39,7 @@ while [ $# -gt 0 ]; do
-x|--xms) XMS="${2:-}"; shift 2 ;; -x|--xms) XMS="${2:-}"; shift 2 ;;
-X|--xmx) XMX="${2:-}"; shift 2 ;; -X|--xmx) XMX="${2:-}"; shift 2 ;;
-N|--neoforge) NFVER="${2:-}"; shift 2 ;; -N|--neoforge) NFVER="${2:-}"; shift 2 ;;
-m|--mc) MCVER="${2:-}"; shift 2 ;;
-A|--admin) ADMIN="${2:-}"; shift 2 ;; -A|--admin) ADMIN="${2:-}"; shift 2 ;;
--accept-eula) ACCEPT_EULA=1; shift ;; --accept-eula) ACCEPT_EULA=1; shift ;;
-h|--help) usage 0 ;; -h|--help) usage 0 ;;
@ -88,6 +90,37 @@ fi
# -------------------------------------------------------------- neoforge ---- # -------------------------------------------------------------- neoforge ----
# NeoForge versions are <mc-minor>.<mc-patch>.<build>, so 1.21.1 -> 21.1.x and
# 1.21 -> 21.0.x. Resolve the newest stable build in that series from the
# NeoForged maven; the [0-9]+$ anchor keeps betas out.
resolve_neoforge() {
local mc="$1" prefix rest meta
rest="${mc#1.}"
case "$rest" in
*.*) prefix="$rest" ;;
*) prefix="${rest}.0" ;;
esac
meta="$(curl -fsSL --max-time 25 \
https://maven.neoforged.net/releases/net/neoforged/neoforge/maven-metadata.xml 2>/dev/null)" \
|| return 1
printf '%s' "$meta" \
| grep -oE '<version>[^<]+</version>' \
| sed -e 's/<[^>]*>//g' \
| grep -E "^${prefix//./\\.}\.[0-9]+$" \
| sort -V | tail -1
}
if [ "$NFVER" = "latest" ]; then
info "resolving latest NeoForge for Minecraft $MCVER"
NFVER="$(resolve_neoforge "$MCVER" || true)"
[ -n "$NFVER" ] || die "could not resolve a NeoForge version for Minecraft $MCVER
Pick one manually from https://projects.neoforged.net/neoforged/neoforge
and pass it with -N <version>."
info "resolved NeoForge $NFVER"
fi
if [ -n "$NFVER" ]; then if [ -n "$NFVER" ]; then
info "installing NeoForge $NFVER server into $SHARE" info "installing NeoForge $NFVER server into $SHARE"
url="https://maven.neoforged.net/releases/net/neoforged/neoforge/${NFVER}/neoforge-${NFVER}-installer.jar" url="https://maven.neoforged.net/releases/net/neoforged/neoforge/${NFVER}/neoforge-${NFVER}-installer.jar"