From 893794bba728ef62ae1df4f8d2f5acda5ed51929 Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Sun, 7 Dec 2025 15:39:16 +0100 Subject: [PATCH] =?UTF-8?q?Script=20de=20d=C3=A9marrage=20du=20serveur=20d?= =?UTF-8?q?e=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 test.sh diff --git a/test.sh b/test.sh new file mode 100755 index 00000000..ad2a0b52 --- /dev/null +++ b/test.sh @@ -0,0 +1,21 @@ +#!/run/current-system/sw/bin/bash +set -euo pipefail + +detect_dev_host() { + local ip_bin="/run/current-system/sw/bin/ip" + [ -x "$ip_bin" ] || { echo "Binaire ip introuvable : $ip_bin" >&2; exit 1; } + + local iface candidate + iface="$("$ip_bin" -4 route show default | awk 'NR==1 {print $5}')" + [ -n "$iface" ] || { echo "Impossible de déterminer l'interface par défaut." >&2; exit 1; } + + candidate="$("$ip_bin" -4 addr show dev "$iface" scope global | awk '/inet / {print $2}' | cut -d/ -f1 | head -n1)" + [ -n "$candidate" ] || { echo "Aucune adresse IPv4 trouvée sur l'interface $iface." >&2; exit 1; } + + printf '%s\n' "$candidate" +} + +DEV_HOST="$(detect_dev_host)" +DEV_PORT=1313 + +hugo server -DEF --bind "$DEV_HOST" --port $DEV_PORT --baseURL "http://$DEV_HOST:$DEV_PORT" \ No newline at end of file