#!/bin/sh
# Initialize default hostname for hostname.d pattern
# This runs very early in boot to set up the default hostname entry

HOSTNAME_D="/etc/hostname.d"

# Ensure directory exists
mkdir -p "$HOSTNAME_D"

# If no default exists yet, create it from /etc/hostname (from squashfs)
if [ ! -f "$HOSTNAME_D/10-default" ] && [ -f /etc/hostname ]; then
    cp /etc/hostname "$HOSTNAME_D/10-default"
fi

# Apply hostname using the deterministic helper
if [ -x /usr/libexec/infix/hostname ]; then
    /usr/libexec/infix/hostname
fi
