#! /bin/sh --

# kbdconfig - simple configuration script for the 'kbd'-package
# Copyright (c) 1996  Dominik Kubla

#CONFFILE=/tmp/kbdconfig.$$
CONFFILE=/etc/kbd/config
LIBDIR=/usr/lib/kbd

#stty sane
#stty tabs

if [ -f $CONFFILE ]
then
	OLDTERM=$TERM
	. $CONFFILE
	TERMTYP=$TERM
	TERM=$OLDTERM
	unset OLDTERM
fi

cat << EOT

             kbdconfig v1.1  -  Copyright (C)1996  Dominik Kubla

EOT

if [ -c /dev/systty ] 
then
	if [ "$CONSOLE" != "/dev/systty" ]
	then
		cat << EOT

This system apparently supports the /dev/systty interface for the console.
If this system does not support the interface, you should remove the 
/dev/systty character device file and re-run kbdconfig.

Linking /dev/console to /dev/systty.

EOT
		consdev=/dev/systty
	else
		consdev=/dev/tty0
	fi
fi

# Some people prefer customized terminal types, eg for higher resolutions
echo -n "Select console type [$TERMTYP]: "; read termtyp
test -z "$termtyp" && termtyp=$TERMTYP

cat << EOT

Please choose one of the following keyboard tables for the VT devices:
----------------------------------------------------------------------
EOT
(cd $LIBDIR/keytables; ls -x)

echo -e "\nOr answer NONE to skip the loading of a keytable."
echo -n "What keytable to load? [$KEYMAP] "; read keymap
if [ -z "$keymap" ] 
then
	if [ -n "$KEYMAP" ]
	then
		keymap=$KEYMAP
	else
		keymap=NONE
	fi
fi

cat << EOT

Please choose one of the following display fonts for the VT devices:
--------------------------------------------------------------------
EOT
(cd $LIBDIR/consolefonts; ls -x)

echo -e "\nOr answer NONE to skip the loading of a consolefont."
echo -n "What consolefont to load? [$SOFTFONT] "; read softfont
if [ -z "$softfont" ]
then
	if [ -n "$SOFTFONT" ]
	then
		softfont=$SOFTFONT
	else
		softfont=NONE
	fi
fi

# ##### NOT YET ... #####
#if [ -n "$advanced_flag"  ]
#then
#	echo -e "\nAdvanced configuration options:"
#	echo "-------------------------------"
#	echo -n "Please enter the number of VT's to be initialized [$VTNUM]: "; read vtnum
#	echo -n "Should the NUMLOCK flag be set by default [$NUMLOCK]: "; read numlock
#	echo -n "Should the METABIT flag be set by default [$METABIT]: "; read numlock
#fi

echo -n  "Generating $CONFFILE... "
cat > $CONFFILE << EOT
CONSOLE=$consdev
TERM=$termtyp
KEYMAP=$keymap
SOFTFONT=$softfont
EOT
echo "done."
exit 0
