server: start.sh/setup.sh relancent automatiquement via nix-shell si Java 25 absent

Sur NixOS, sans nix-shell le java systeme manque souvent. Le script detecte
l'absence de Java 25 et se re-execute dans le shell Nix du repo (shell.nix),
avec garde SURVIEPOTE_NIX pour eviter toute boucle.
This commit is contained in:
Anaïs Saraiva
2026-10-19 20:11:09 +02:00
parent 3a2b403acc
commit b8a283a177
2 changed files with 21 additions and 10 deletions
+8 -3
View File
@@ -1,11 +1,16 @@
# SurviePote — lancement serveur Fabric MC 26.3 / Loader 0.20.0 / Java 25
# Recommandé : nix-shell (voir ../shell.nix + ../.envrc) pour avoir Java 25 + Node 22.
cd "$(dirname "$0")"
ROOT="$(cd .. && pwd)"
# MC 26.3 exige Java 25 (class file version 69.0).
# Java 25 absent -> on se replace dans le shell Nix du repo (NixOS / nix-shell).
if ! java -version 2>&1 | grep -q 'version "25'; then
if [ -z "${SURVIEPOTE_NIX:-}" ] && command -v nix-shell >/dev/null 2>&1 && [ -f "$ROOT/shell.nix" ]; then
echo "Java 25 absent -> relance dans le shell Nix du repo (nix-shell)..."
export SURVIEPOTE_NIX=1
exec nix-shell "$ROOT" --run "bash '$ROOT/server/start.sh'"
fi
echo "ERREUR: Java 25 requis (java actuel : $(java -version 2>&1 | head -1))."
echo "Lance via nix-shell : nix-shell .. --run './start.sh' (ou direnv allow à la racine)."
echo "Lance depuis la racine du repo : nix-shell . --run 'bash server/start.sh'"
exit 1
fi