#!/bin/sh -e
. /usr/share/debconf/confmodule

# Display some final messages. These messages are only displayed if this
# script is being run on a newly installed system. Such a system will have
# dbootstrap_settings.
if [ -e /root/dbootstrap_settings ]; then
	. /root/dbootstrap_settings || true
	
	db_get base-config/username
	USERNAME="$RET"
	if [ "$USERNAME" ]; then
		db_subst base-config/login users "'root' or '$USENAME'"
		db_subst base-config/login-with-tty users "'root' or '$USERNAME'"
	else
		db_subst base-config/login users "'root'"
		db_subst base-config/login-with-tty users "'root'"
	fi
	# Only display the VT message if they seem to be at a tty.
	# TODO: the messages about logging in and switching tty's should
	# be split up, but it makes sense to combine them for potato since
	# only the dialog frontend is available.
	if [ "$SERIALCONSOLE" == true ]; then
		db_input medium base-config/login || true
	else
		db_input medium base-config/login-with-tty || true
	fi
	db_go || true

	# Clear the screen, in preparation for the login prompt
	clear >/dev/tty </dev/tty
fi
