#!/bin/bash
# Regenerates /etc/issue so the live-ISO console tells the user which URL
# to open in their browser. Shows proksi.local (via avahi/mDNS) as the
# preferred URL and the raw IP as a fallback for networks where mDNS
# doesn't work. Reload at the end nudges agetty to redraw.
set -e

ip=$(ip -4 -o addr show scope global 2>/dev/null | awk '{print $4}' | cut -d/ -f1 | head -1)

{
    echo
    echo "  Open Furtka in a browser on another device on your network:"
    echo
    echo "      http://proksi.local:5000   (easy — try this first)"
    if [ -n "$ip" ]; then
        echo "      http://${ip}:5000   (fallback if the first doesn't work)"
    fi
    echo
    echo "  Then follow the wizard to install Furtka on this machine."
    echo
} > /etc/issue

agetty --reload 2>/dev/null || true
