Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-testing > by-pkgid > f41fdd9f120285860041043db6b74f73 > files > 6

kbd-1.12-14.2mdv2008.1.x86_64.rpm

#!/bin/sh
#
# Load keytable
#
# This must be executed *after* /usr is mounted.
# This means is /usr is NFS-mounted, it needs to
# run after networking and NFS mounts are up.
#
# chkconfig: 2345 14 05
# description: This package loads the selected keyboard map as set in \
#   /etc/sysconfig/keyboard. You should leave this enabled for most \
#   machines.
# config: /etc/sysconfig/keyboard
#
### BEGIN INIT INFO
# Provides: keytable
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Should-Start: $remote_fs
# Should-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Short-Description: Load keytable
# Description: This package loads the selected keyboard map as set in
#              /etc/sysconfig/keyboard. You should leave this enabled
#              for most machines.
### END INIT INFO

# X-Parallel-Init
# X-Parallel-Requires: netfs

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

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

# Source function library
. /etc/rc.d/init.d/functions

# If CHARSET is not defined, try to see what the current
# locale encoding is (we only want to know if it is UTF-8 or not)
[ -n "$CHARSET" ] || CHARSET="`get_locale_encoding`"

case "$1" in
	start)
		# Read the keyboard config
		. /etc/sysconfig/keyboard
		if [ "${KEYTABLE:-bogus}" != "bogus" ]; then
			# load the keyboard map
			if [ "$CHARSET" = "UTF-8" ]; then
				case "$KEYTABLE" in
					*uni|*.uni.*)
						UNIKEYTABLE="$KEYTABLE"
						;;
					*map*)
						UNIKEYTABLE="`echo $KEYTABLE | \
						              sed 's/.map/.uni.map/'`"
						;;
					*)
						UNIKEYTABLE="${KEYTABLE}.uni"
						;;
				esac
				gprintf "Loading keymap: %s" "$KEYTABLE"
				if ! loadkeys $UNIKEYTABLE 2> /dev/null; then
					loadkeys -u $KEYTABLE 2> /dev/null \
						&& success || failure
				else
					success
				fi
				echo
			else
				action "Loading keymap: %s" "$KEYTABLE" \
				loadkeys $KEYTABLE 2> /dev/null
			fi
		fi

		if [ "$BACKSPACE" = "BackSpace" ]; then
			gprintf "The BackSpace key sends: ^H"
			loadkeys backspace 2> /dev/null \
				&& success || failure
		else
			gprintf "The BackSpace key sends: ^?"
			loadkeys delete 2> /dev/null \
				&& success || failure
		fi
		echo

		if [ -n "$GRP_TOGGLE" ]; then
			action "Loading toggle definition: %s" \
			       "$GRP_TOGGLE" loadkeys ${GRP_TOGGLE} \
			       2> /dev/null
		fi

		touch /var/lock/subsys/keytable
		;;
	stop)
		rm -f /var/lock/subsys/keytable
		;;
	restart|reload)
		$0 start
		;;
	status)
		gprintf "No status available for this package\n"
		exit 0
		;;
	*)
		gprintf "Usage: keytable {start|stop|restart|reload|status}\n"
		exit 1
esac

exit 0