Add one-command server mod updates: build_mods.py --push via update.sh (stop/sync/start, prunes stale jars)
This commit is contained in:
+11
-2
@@ -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."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user