#!/bin/sh -e
# Keyboard configuration.
#
# Note that this needs to run before any stuff that might ask for keyboard
# input..

ETC_FILE=/etc/console/boottime.kmap.gz

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

if [ "$1" = with_debconf ]; then
	. /usr/share/debconf/confmodule

	if [ ! -e $ETC_FILE ]; then
		# Work out the keymap file to install.
		if [ "$KEYBD" ]; then
			KEYMAP=/usr/share/keymaps/${KEYBD}.kmap.gz
		else
			db_get debian-installer/keymap
			KEYMAP=$(find /usr/share/keymaps/ -name "$RET.kmap*")
		fi
		
		if [ ! -z "$KEYMAP" ]; then
			install-keymap $KEYMAP >/dev/null || true
		fi
	fi
else
	$0 with_debconf
	if [ ! -e $ETC_FILE ]; then
		# This part cannot be run under debconf.
		if [ ! -e $ETC_FILE -a -f /bin/loadkeys ]; then
			dpkg-reconfigure --unseen-only --default-priority console-data || true
		fi
	fi
fi
