SciCraft/tools/pterodactyl-start.sh
MiTHRAL a88a0c2421
All checks were successful
Build & Release Pack / build (push) Successful in 1m38s
fix: B1 patch worldportal no EntityLMixin (fixes sable mixin crash) + pterodactyl startup
- Patch worldportal-neoforge-0.0.10+1.21: remove EntityLMixin (priority 750
  @WrapOperation getRelativePortalPosition) which conflicts with sable
  EntityMixin @Overwrite (priority 1000). Keeps other 10 mixins
  (EntityMixin, PortalForcerLMixin, etc.) so Void Dimension portals still
  work. IPSable 0.5.0 only fixes Entity::collide, not this method, so
  worldportal must be patched directly. Patched jar at tools/patches/
  with sha512 efbf5fac... and pw.toml now points to
  https://git.mithraic.cloud/.../tools/patches/worldportal-...-patched.jar
  (side=server, both packs).

- Add tools/pterodactyl-start.sh: correct NeoForge 21.1.248 Pterodactyl
  startup for yolks:java_21 egg. Handles packwiz -s server, neoforge
  installer (--installServer generates user_jvm_args.txt + unix_args.txt +
  run.sh), injects {{SERVER_MEMORY}} into user_jvm_args.txt (replaces
  -Xmx), and exec bash run.sh nogui (correct order
  java @user_jvm_args.txt @unix_args.txt). Replaces broken
  Hytale/start.sh exec java @unix_args.txt (missing user_jvm_args,
  hardcoded -Xms128M, no nogui, no run.sh, wrong CWD).

- Also fixed Hytale/start.sh to delegate to new script.
2026-08-24 00:07:32 -04:00

80 lines
3.8 KiB
Bash
Executable file

#!/bin/bash
# Pterodactyl NeoForge 21.1.248 startup for SciCraft
# Egg: ghcr.io/pterodactyl/yolks:java_21
# Startup Command in Panel: bash tools/pterodactyl-start.sh
# Or: bash run.sh (if you prefer the egg's default)
set -e
echo "======================================"
echo " SciCraft - Pterodactyl Bootstrap"
echo " NeoForge 21.1.248 | packwiz"
echo "======================================"
# 1. Install packwiz mods if pack.toml changed
if [ ! -f packwiz-installer-bootstrap.jar ]; then
echo "[Ptero] Downloading packwiz installer..."
curl -fsSL -o packwiz-installer-bootstrap.jar https://github.com/packwiz/packwiz-installer-bootstrap/releases/latest/download/packwiz-installer-bootstrap.jar
fi
echo "[Ptero] Syncing server pack..."
# Use local server_pack/pack.toml if present (Pterodactyl clones the repo), else fall back to git raw
if [ -f server_pack/pack.toml ]; then
java -jar packwiz-installer-bootstrap.jar -g -s server server_pack/pack.toml
elif [ -f pack.toml ]; then
java -jar packwiz-installer-bootstrap.jar -g -s server pack.toml
else
# Fallback to remote (for Hytale misplaced folder)
java -jar packwiz-installer-bootstrap.jar -g -s server https://git.mithraic.cloud/ad3laid3/SciCraft/raw/branch/main/server_pack/pack.toml
fi
# 2. Install NeoForge server if missing (generates user_jvm_args.txt, unix_args.txt, run.sh)
if [ ! -f libraries/net/neoforged/neoforge/21.1.248/unix_args.txt ]; then
echo "[Ptero] Installing NeoForge 21.1.248 server..."
if [ ! -f neoforge-21.1.248-installer.jar ]; then
curl -fsSL -o neoforge-21.1.248-installer.jar https://maven.neoforged.net/releases/net/neoforged/neoforge/21.1.248/neoforge-21.1.248-installer.jar
fi
java -jar neoforge-21.1.248-installer.jar --installServer
fi
# 3. Ensure user_jvm_args.txt exists and respects Pterodactyl memory
# Pterodactyl injects {{SERVER_MEMORY}} as env var SERVER_MEMORY (MB)
# Preset: medium tier (4G-8G). Adjust via presets/low|high if needed
if [ ! -f user_jvm_args.txt ]; then
echo "[Ptero] Creating user_jvm_args.txt from preset..."
if [ -f presets/medium/server/jvm-flags.txt ]; then
cp presets/medium/server/jvm-flags.txt user_jvm_args.txt
elif [ -f server_pack/../presets/medium/server/jvm-flags.txt ]; then
cp server_pack/../presets/medium/server/jvm-flags.txt user_jvm_args.txt
else
# Fallback minimal
echo "-Xms4G -Xmx8G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -Dlog4j2.formatMsgNoLookups=true" > user_jvm_args.txt
fi
fi
# Inject Pterodactyl memory if available (SERVER_MEMORY is in MB)
if [ -n "$SERVER_MEMORY" ]; then
echo "[Ptero] Detected Pterodactyl SERVER_MEMORY=${SERVER_MEMORY}M, patching user_jvm_args.txt..."
# Replace -Xmx value with Pterodactyl's allocation
sed -i -E "s/-Xmx[0-9]+[GM]/-Xmx${SERVER_MEMORY}M/g" user_jvm_args.txt
# Ensure -Xms is half of max or 4G min
if grep -q "MaxRAMPercentage" user_jvm_args.txt; then
sed -i -E "s/-XX:MaxRAMPercentage=[0-9.]+//g" user_jvm_args.txt
fi
fi
# 4. Ensure run.sh is executable and correct
if [ ! -f run.sh ]; then
echo "[Ptero] run.sh missing, regenerating..."
echo '#!/usr/bin/env sh' > run.sh
echo 'java @user_jvm_args.txt @libraries/net/neoforged/neoforge/21.1.248/unix_args.txt "$@"' >> run.sh
fi
chmod +x run.sh
echo "======================================"
echo " Starting SciCraft NeoForge 21.1.248"
echo " user_jvm_args.txt: $(cat user_jvm_args.txt | tr '\n' ' ')"
echo " unix_args.txt exists: $(test -f libraries/net/neoforged/neoforge/21.1.248/unix_args.txt && echo yes || echo no)"
echo "======================================"
# Pterodactyl expects to keep PID 1 and handle signals, so exec run.sh
exec bash run.sh nogui