#!/bin/sh
#
# Load keytable
#
# chkconfig: 12345 17 05
# description: This package loads the selected keyboard map as set in \
#   /etc/sysconfig/keyboard.  This can be selected using the kbdconfig \
#   utility.  You should leave this enabled for most machines.
# config: /etc/sysconfig/keyboard

[ -f /etc/sysconfig/keyboard ] || exit 0

[ -f /bin/loadkeys ] || exit 0


. /etc/init.d/functions

RETVAL=$?

start() {
		. /etc/sysconfig/keyboard
		if [ "${KEYTABLE:-bogus}" != "bogus" ]; then
			# Load the proper keymap
			# Specify VT0 in case we use a serial console
			echo -n $"Loading keymap: "
			loadkeys $KEYTABLE < /dev/tty0 > /dev/null 2>&1
			RETVAL=$?
			[ $RETVAL -eq 0 ] && success "Loading keymap: "
			[ $RETVAL -ne 0 ] && failure "Loading keymap: "
			echo
		fi
		[ -x /sbin/setsysfont ] && action $"Loading system font: " /sbin/setsysfont
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/keytable
}

stop() {
	rm -f /var/lock/subsys/keytable
}

restart() {
	$0 start
	RETVAL=$?
}

status() {
	echo $"No status available for this package"
	exit 0
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		restart
		;;
	status)
		status
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
		exit 1
esac

exit $RETVAL
