Add one-command server mod updates: build_mods.py --push via update.sh (stop/sync/start, prunes stale jars)

This commit is contained in:
2026-08-21 10:58:38 +02:00
parent 7475ce0942
commit 89c0c47bb1
5 changed files with 247 additions and 13 deletions
+11 -2
View File
@@ -5,7 +5,7 @@
# Installs everything needed to run the Reaper's Sky NeoForge 21.1.248 server:
# - OpenJDK 21 (JRE, headless) + curl/unzip
# - NeoForge 21.1.248 server via its official installer
# - the 88 server-safe mods (pinned in mods.json, verified by sha1)
# - the server-safe mods (pinned in mods.json, verified by sha1)
# - eula.txt + server.properties (IP reaperofveriod.nl)
# - run.sh (8 GB, G1GC)
#
@@ -74,8 +74,10 @@ install_mods() {
python3 - "$SCRIPT_DIR/mods.json" <<'PY'
import json, sys, hashlib, subprocess, os
manifest = json.load(open(sys.argv[1]))
keep = set()
for m in manifest["mods"]:
fname, url, want = m["file"], m["url"], m["sha1"]
keep.add(fname)
tmp = fname + ".part"
if os.path.exists(fname):
h = hashlib.sha1()
@@ -84,7 +86,9 @@ for m in manifest["mods"]:
h.update(b)
if h.hexdigest() == want:
continue # already present & correct
subprocess.run(["curl", "-fL", "--retry", "3", "-o", tmp, url], check=True)
if not url:
raise SystemExit(f"no download URL for {fname}")
subprocess.run(["curl", "-fsSL", "--retry", "3", "-o", tmp, url], check=True)
h = hashlib.sha1()
with open(tmp, "rb") as fh:
for b in iter(lambda: fh.read(65536), b""):
@@ -94,6 +98,11 @@ for m in manifest["mods"]:
raise SystemExit(f"sha1 mismatch for {fname}")
os.rename(tmp, fname)
print(f" + {fname}")
# remove jars that are no longer part of the pack
for f in sorted(os.listdir(".")):
if f.endswith(".jar") and f not in keep:
os.unlink(f)
print(f" - {f} (stale)")
PY
log "Mods ready: $(ls -1 "$SERVER_DIR/mods"/*.jar | wc -l) jars installed."
}