#!/bin/bash
# Regenerates /etc/issue on the installed system so the console tells the
# user which URL to open. Mirrors the live-ISO furtka-update-issue pattern.
set -e

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

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

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