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

if [ -e /root/dbootstrap_settings ]; then
	. /root/dbootstrap_settings || true
fi	

# Display some final messages. These messages are only displayed if this
# script is being run on a system that has no-one logged in. If someone
# is logged in, they must either know what they are doing, or they must
# be reconfiguring or installing this package. We only want to show this
# stuff if they have just booted up a fresh debian system.
if [ -z "`who`" ]; then
	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
