kbd.new 5.59 KB
Newer Older
Nico Schottelius's avatar
init  
Nico Schottelius committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
#!/bin/sh
# 
# Author: Nico Schottelius <nico AT schottelius DOT org>
# Date: 30. April 2k+1
# Last Changed: 30. April 2k+1
# Comment: Keyboard (KBD) init script
#

. /etc/sys/combined
. /etc/sys/boot/named

test `basename $0` = named && START_KBD="yes"
test "$START_KBD" = yes || exit 0

back="$DONE"

case "$1" in
    start)	$SYS_ECHO -n "$START $KBD_TEXT "
		|| back=$FAIL
		$SYS_ECHO "$back"
		;;
    stop)	$SYS_ECHO -n "$STOP $NAMED_TEXT "
    		killproc -TERM /usr/sbin/named || back=$FAIL
		$SYS_ECHO "$back"
		;;
    restart)
		$0 stop && $0 start || back=$FAIL
		;;
    reload)   	$SYS_ECHO -n "$RELOAD $NAMED_TEXT"
              	killproc -HUP /usr/sbin/named || back=$FAIL
	      	$SYS_ECHO "$back"
              	;;
    status)	checkproc /usr/sbin/named && $SYS_ECHO $OK || $SYS_ECHO $NOP
    		;;
    *)		$SYS_ECHO  "$USAGE $0 {start|stop|restart|reload|status}"
		exit 1
esac


# Test if back is equal to DONE, if not exit 1. Else exit 0
test "$back" = "$DONE" || exit 1
exit 0





#! /bin/sh
# Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
#
# Author:   Burchard Steinbild <bs@suse.de>
#           Werner Fink <werner@suse.de>
#
# /sbin/init.d/kbd
#
#   and symbolic its link
#
# /sbin/rckbd
#
### BEGIN INIT INFO
# Provides:       kbd
# Required-Start: $remote_fs
# Required-Stop:
# Default-Start:  1 2 3 5 S
# Default-Stop:
# Description:    Keyboard settings
### END INIT INFO

. /etc/rc.status
. /etc/rc.config

MACHINE=`/bin/uname -m 2> /dev/null`
if [ "$MACHINE" = "sparc" -o "$MACHINE" = "sparc64" ]; then 
   # Test if we have a serial console. 
   (test -c /dev/tty1 && > /dev/tty1 ) > /dev/null 2>&1 || exit 0
fi

test -n "$KEYTABLE" -a "$KEYTABLE" != YAST_ASK || {
    echo KEYTABLE is not set in /etc/rc.config.  Exit.
    exit 0
}
KEYTABLE=${KEYTABLE%.map*}
#
# first search the wanted keytable.
#
if [ $MACHINE = ppc ]; then
	test -f /proc/cpuinfo || mount -n -t proc proc /proc 2>/dev/null
	while read line; do
	       case "$line" in
		  *MacRISC*)	MACHINE="mac";;
		  *CHRP*)  	MACHINE="chrp";;
		  *PReP*)  	MACHINE="prep" ;;
		esac
	done < /proc/cpuinfo
fi

case "$MACHINE" in
  i?86|ia64|alpha|prep|chrp) KDBLIB="/usr/lib/kbd/keymaps/i386/*/"     ;;
  sparc*)    
     case "$KEYTABLE" in
        sun*) KDBLIB="/usr/lib/kbd/keymaps/sun/"        ;;
        *)    KDBLIB="/usr/lib/kbd/keymaps/i386/*/"     ;;
     esac
     ;;
  mac)       KDBLIB="/usr/lib/kbd/keymaps/mac/" ;;
  *)         echo "No available keymaps for machine $MACHINE found"; exit 1
	;;

esac

KEYMAP=""
if test -e /$KEYTABLE ; then
    KEYMAP=$KEYTABLE
else
    K="${KDBLIB}${KEYTABLE}"
    case "$KEYTABLE" in
	*.gz)  KDBPATH="${K}" ;;
	*.map) KDBPATH="${K} ${K}.gz" ;;
	*)     KDBPATH="${K} ${K}.gz ${K}.map.gz ${K}.map" ;;
    esac
    for K in ${KDBPATH} ; do	
	test -e "$K" || continue
	test -n "$KEYMAP" && KEYMAP="$KEYMAP $K" || KEYMAP=$K
    done
fi

rc_reset
case "$1" in
    start|restart|reload)
	if test -z "$KEYMAP" ; then
	    if test -r /etc/defkeymap.map ; then
		echo "Can not find a keymap for ${KEYTABLE}, trying fallback."
		KEYMAP=/etc/defkeymap.map
	    else
		echo "Can not find a keymap for ${KEYTABLE}, Exit."
		rc_failed
	    fi
	else
	    if test ! -e "$KEYMAP" ; then
		echo "Found more than one keymap ${KEYTABLE}"
		KEYMAP=$K
		echo "Using $KEYMAP."
		echo "If you want another one, please add complete path to"
		echo "KEYTABLE in /etc/rc.config."
	    fi
	fi
	rc_status && retmsg="`loadkeys $KEYMAP 2>&1`"
	if test $? -eq 0 && ( > /var/run/keymap ) > /dev/null 2>&1 ; then
	    echo "$KEYMAP"    > /var/run/keymap
	    if test ! -s /etc/defkeymap.map ; then
		( dumpkeys > /etc/defkeymap.map ) > /dev/null 2>&1
	    fi
	else
	    rc_failed
	fi
	echo "Loading keymap ${retmsg#Loading*/usr/lib/kbd/keymaps/*/}"
	rc_status -v1 -r

	# Load compose tables
	if test ! -z "$COMPOSETABLE"; then
		unset COMPOSELOADED COMPOSECLEAR
		for name in $COMPOSETABLE; do
			# Test for compose clear flag
			if test "$name" = "-c" -o "$name" = "clear"; then
				COMPOSECLEAR=-c
				continue
			fi
			# Handle the first table differently ...
			if test -z "$COMPOSELOADED"; then
				echo -n "Loading compose table $name"
				loadkeys $COMPOSECLEAR compose.$name >/dev/null 2>&1
				rc_check
				if test $name = clear; then rc_reset; fi
				COMPOSELOADED=1
			else
				echo -n " $name"
				loadkeys compose.$name >/dev/null 2>&1
				rc_check
			fi
		done
		if test ! -z "$COMPOSELOADED"; then 
			rc_status -v -r
		fi
	fi
	
	# setfont
	if test -d /usr/lib/kbd/consolefonts -a \
		-n "$CONSOLE_FONT" -a "$CONSOLE_FONT" != "YAST_ASK"
	then
	    if test -x /usr/bin/setfont ; then
		echo Loading console font $CONSOLE_FONT
		/usr/bin/setfont $CONSOLE_FONT
		rc_status -v1 -r
	    fi
	    # unimap
	    if test -n "$CONSOLE_UNICODEMAP" -a \
		    "$CONSOLE_UNICODEMAP" != "none" -a \
		    -x /usr/bin/setfont
	    then
		echo Loading unimap $CONSOLE_UNICODEMAP
		/usr/bin/setfont -u $CONSOLE_UNICODEMAP
		rc_status -v1 -r
	    fi
	    # screenmap
	    if test -n "$CONSOLE_SCREENMAP" -a \
		    "$CONSOLE_SCREENMAP" != "none" -a \
		    -x /usr/bin/setfont
	    then
		echo Loading screenmap $CONSOLE_SCREENMAP
		/usr/bin/setfont -m $CONSOLE_SCREENMAP
		rc_status -v1 -r
	    fi
	    # console magic init string
	    if test -n "$CONSOLE_MAGIC" -a "$CONSOLE_MAGIC" != "none" ; then
		echo Setting up console ttys
		for i in /dev/tty[1-24]; do
		    echo -en "\033$CONSOLE_MAGIC" > $i
		    rc_status
		done
		rc_status -v1 -r
	    fi
	fi

	;;
    stop)
	;;
    check|status)
	if test -r /var/run/keymap ; then
	    read current < /var/run/keymap
	    echo "Keymap $current is loaded."
	else
	    rc_failed
	fi
	;;
    *)
	echo "Usage: $0 {start|stop|restart|reload|status|check}"
	exit 1
	;;
esac
rc_exit