1
Files
2025/test.sh

21 lines
780 B
Bash
Executable File

#!/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"