#! /bin/sh

set -e

# postinst - script to finish installation of the `console-tools' package.
# (c) 1997-2000  Yann Dirson
# (c) 1996  Dominik Kubla

CONFDIR=/etc/console-tools

test -x /usr/sbin/install-docs && install-docs -i /usr/share/doc-base/lct || true

# compress any uncompressed default kmap
if [ -r ${CONFDIR}/default.kmap ]; then
    if [ -r ${CONFDIR}/default.kmap.gz ]; then
	# both exist !  Keep newest one
	if [ ${CONFDIR}/default.kmap -nt ${CONFDIR}/default.kmap.gz ]; then
	    gzip -9f ${CONFDIR}/default.kmap
	else
	    rm -f ${CONFDIR}/default.kmap
	fi
    else
	gzip -9 ${CONFDIR}/default.kmap
    fi
fi

DONE=0

# if [ "$1" = "configure" -a -r /usr/share/debconf/confmodule ]
# then # use debconf
#     . /usr/share/debconf/confmodule

#     if [ -z "$RET" ] || ! db_get shared/keymap/keymap_filename
#     then
# 	db_stop
#     else
# 	keymap="$RET"
# 	/usr/sbin/install-keymap $keymap
# 	DONE=1
#     fi
# fi

# if debconf not installed OR /usr/sbin/install-keymap is empty
if [ $DONE = 0 \
     -a ! -r ${CONFDIR}/default.kmap -a ! -r ${CONFDIR}/default.kmap.gz ]
then
    echo "  You now use the default keyboard layout of the kernel."
    echo "   (unless you changed it manually)"
    echo
    echo "  You may want it to match your actual keyboard (which is most likely"
    echo "   for non-american keyboards); just press RETURN to the following"
    echo "   prompt if you're happy with the defaults."
    echo "  You'll be able to change it again at any time by running"
    echo "   /usr/sbin/kbdconfig."

    /usr/sbin/kbdconfig
fi

# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
	if [ -d /usr/doc -a ! -e /usr/doc/console-tools -a -d /usr/share/doc/console-tools ]; then
		ln -sf ../share/doc/console-tools /usr/doc/console-tools
	fi
fi
# End automatically added section
# Automatically added by dh_installinit
update-rc.d keymaps-lct.sh start 05 S . >/dev/null
if [ "$1" = "configure" ]; then
	if [ -z "$2" -o "$2" = "<unknown>" ]; then
		/etc/init.d/keymaps-lct.sh start
	fi
fi
# End automatically added section
# Automatically added by dh_installinit
update-rc.d console-screen.sh start 48 S . >/dev/null
if [ "$1" = "configure" ]; then
	if [ -z "$2" -o "$2" = "<unknown>" ]; then
		/etc/init.d/console-screen.sh start
	fi
fi
# End automatically added section

