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:
+13
-7
@@ -1,9 +1,21 @@
|
|||||||
# SurviePote — installe/repare le runtime serveur Fabric (MC 26.3 / Loader 0.20.0).
|
# SurviePote — installe/repare le runtime serveur Fabric (MC 26.3 / Loader 0.20.0).
|
||||||
# Les jars vanilla/Fabric, libraries/ et versions/ ne sont PAS versionnes (voir .gitignore) :
|
# Les jars vanilla/Fabric, libraries/ et versions/ ne sont PAS versionnes (voir .gitignore) :
|
||||||
# ce script les (re)genere dans le dossier courant. A lancer une fois sur le serveur, avant ./start.sh.
|
# ce script les (re)genere dans le dossier courant. A lancer une fois sur le serveur, avant ./start.sh.
|
||||||
# Requiert Java (idealement Java 25, ex. via nix-shell à la racine du repo).
|
|
||||||
set -e
|
set -e
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
ROOT="$(cd .. && pwd)"
|
||||||
|
|
||||||
|
# Java absent -> on se replace dans le shell Nix du repo (NixOS / nix-shell).
|
||||||
|
if ! command -v java >/dev/null 2>&1; then
|
||||||
|
if [ -z "${SURVIEPOTE_NIX:-}" ] && command -v nix-shell >/dev/null 2>&1 && [ -f "$ROOT/shell.nix" ]; then
|
||||||
|
echo "Java absent -> relance dans le shell Nix du repo (nix-shell)..."
|
||||||
|
export SURVIEPOTE_NIX=1
|
||||||
|
exec nix-shell "$ROOT" --run "bash '$ROOT/server/setup.sh'"
|
||||||
|
fi
|
||||||
|
echo "ERREUR: java introuvable."
|
||||||
|
echo "Depuis la racine du repo : nix-shell . --run 'bash server/setup.sh'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
MC_VERSION=26.3
|
MC_VERSION=26.3
|
||||||
LOADER_VERSION=0.20.0
|
LOADER_VERSION=0.20.0
|
||||||
@@ -16,12 +28,6 @@ if [ -f "$LAUNCH_JAR" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
command -v java >/dev/null 2>&1 || {
|
|
||||||
echo "ERREUR: java introuvable."
|
|
||||||
echo "Depuis la racine du repo : nix-shell . --run 'bash server/setup.sh'"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -f "$INSTALLER_JAR" ]; then
|
if [ ! -f "$INSTALLER_JAR" ]; then
|
||||||
echo "== Telechargement de fabric-installer $INSTALLER_VERSION =="
|
echo "== Telechargement de fabric-installer $INSTALLER_VERSION =="
|
||||||
curl -fSL -o "$INSTALLER_JAR" \
|
curl -fSL -o "$INSTALLER_JAR" \
|
||||||
|
|||||||
+8
-3
@@ -1,11 +1,16 @@
|
|||||||
# SurviePote — lancement serveur Fabric MC 26.3 / Loader 0.20.0 / Java 25
|
# 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")"
|
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 ! 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 "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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user