#!/usr/bin/env bash
# One-time personalization from /etc/bc250-console.conf (written at image
# build time by build-console.sh): applies friendly display names to the
# accounts created by the installer. Stamps so it never re-runs — later
# on-box renames/chfn are never overwritten.
[ -r /etc/bc250-console.conf ] && . /etc/bc250-console.conf

apply() { # $1 = user, $2 = display name
    [ -n "$2" ] || return 0
    id "$1" >/dev/null 2>&1 || return 0
    chfn -f "$2" "$1" || true
}

apply "${CONSOLE_KID_USER:-kid}"       "${CONSOLE_KID_DISPLAY:-}"
apply "${CONSOLE_PARENT_USER:-parent}" "${CONSOLE_PARENT_DISPLAY:-}"

mkdir -p /var/lib/bc250
touch /var/lib/bc250/.personalized
