#! /bin/sh
#
# dsetup-kbd: Debian Linux keyboard setup utility (0.93)
#
# Copyright (C) 1994, 1995 Debian Association, Inc.
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

dialog=dialog
tput=tput

bold=`$tput bold`
clear=`$tput clear`
norm=`$tput sgr0`

cat << EOF > /tmp/dinstall.tmp
The default in Debian Linux is the U.S. keyboard.  Are you using
a U.S. keyboard?  (If you live in the U.S., you should answer "Yes".)
EOF

while true
do
  $dialog --title "Keyboard Setup" --yesno "`cat /tmp/dinstall.tmp`" 6 75

  case $? in
    0)
      exit
      ;;
    1)
      break
      ;;
  esac
done

echo -n $clear

again=1
until [ $again -eq 0 ]
do
  echo "The following keytables are available:"
  echo
  ls /target/usr/lib/kbd/keytables
  echo
  echo -n "Which keytable should be loaded at boot time? "
  echo -n $bold
  read keytable
  echo -n $norm
  if [ ! -f /target/usr/lib/kbd/keytables/$keytable ]
  then
    echo
    echo "*** The keytable \`$keytable' does not exist. ***"
    echo
  else
    echo
    echo -n "Setting the keytable to \`$keytable'... "
	if [ ! -d /target/etc/default ]; then
		mkdir /target/etc/default
		chmod 755 /target/etc/default
	fi
cat > /target/etc/default/console << EOF
CONSOLE=/dev/tty0
TERM=linux
KEYMAP="$keytable"
SOFTFONT=""
EOF
    chmod 755 /target/etc/default/console
    echo "done."
    again=0
  fi
done
