]> git.pld-linux.org Git - packages/kbd.git/blame - kbd.init
- fix is_no() call
[packages/kbd.git] / kbd.init
CommitLineData
8a6e015e 1#!/bin/sh
7c0a328f
TP
2
3# console Loads console font and keyboard table
8a6e015e 4#
beabe028 5# chkconfig: 2345 70 30
8a6e015e
AM
6#
7# description: Loads the console font, the application-charset map \
8# and the keyboard table.
9
10# This must be executed *after* /usr is mounted.
7c0a328f
TP
11# This means, if /usr is NFS-mounted it needs to
12# be run after networking and NFS mounts are up.
8a6e015e
AM
13
14[ -f /etc/sysconfig/console ] || exit 0
15
b9aad5cd 16[ -f /bin/loadkeys -o -f /usr/bin/loadkeys ] || exit 0
76396e54 17[ -f /bin/setfont -o -f /usr/bin/setfont ] || exit 0
8a6e015e 18
154b5c25
AM
19[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
20
8a6e015e
AM
21# Source function library
22. /etc/rc.d/init.d/functions
23
31037d9c
JR
24if is_yes "$VSERVER"; then
25 exit 0
26fi
27
6069da61 28. /etc/sysconfig/console
8a6e015e 29
6069da61 30start() {
25983a1f 31 # Checking if we have framebuffer enabled
32 if [ -f /proc/fb ]; then
33 # /proc shows as files with size=0, this is workaround
34 if cat /proc/fb | grep -q "."; then FB=yes; fi
35 fi
36
37 if [ -n "$SVGATEXTMODE" ]; then
38 run_cmd "Setting Text Mode $SVGATEXTMODE" SVGATextMode $SVGATEXTMODE
39 fi
154b5c25 40
3e0052a2 41 # Check for devfs (workaround: -a option doesn't work at all)
42 if [ -d /dev/vc ]; then
1e62a39e 43 devpath="/dev/vc/"
3e0052a2 44 else
1e62a39e 45 devpath="/dev/tty"
3e0052a2 46 fi
47 # save old tty number
1e62a39e
ER
48 tty=$(/usr/bin/tty)
49 tty=${tty#$devpath}
3e0052a2 50 if [ "$tty" = "/dev/console" ]; then
6069da61 51 tty=1
3e0052a2 52 fi
53
76e3812d 54 if [ -n "$CONSOLEFONT" -a -x /sbin/setsysfont ]; then
25983a1f 55 show "Loading console font and map"
56 busy
57
154b5c25
AM
58 # don't initialize on multiple terminals if we use fbset
59 # (assume that, in this case fb is loaded as a module)
60 if [ ! -z "$FB" ]; then
976efedd
ER
61 if [ -z "$SET_FONT_TERMINALS" ]; then
62 # check if devfs (workaround: -a option doesn't work at all)
63 if [ -d /dev/vc ]; then
64 SET_FONT_TERMINALS=$(ls /dev/vc/)
65 else
66 SET_FONT_TERMINALS=$(awk -F: '/^[0-9]*:/{print $1}' /etc/inittab)
67 fi
154b5c25 68 fi
25983a1f 69
154b5c25 70 for cons in $SET_FONT_TERMINALS; do
976efedd 71 /usr/bin/open -c $cons -s -w -- /sbin/setsysfont
154b5c25
AM
72 if [ "$NUM_LOCK" ]; then
73 if [ $NUM_LOCK = "on" ]; then
74 /usr/bin/open -c $cons -s -w -- /usr/bin/setleds -D +num
75 else
76 /usr/bin/open -c $cons -s -w -- /usr/bin/setleds -D -num
77 fi
55dbdd10 78 fi
154b5c25 79 done
e277f7c8 80
976efedd
ER
81 if [[ "$tty" = [0-9]* ]]; then
82 /usr/bin/switchto $tty
83 fi
25983a1f 84 else
e4d53ccd
JR
85 for cons in $SET_FONT_TERMINALS; do
86 /usr/bin/open -c $cons -s -w -- /sbin/setsysfont
87 done
e277f7c8 88 fi
25983a1f 89 ok
90 fi
85209e87 91
25983a1f 92 if [ -n "$KEYTABLE" ]; then
db05817e 93 if [ "$(LANG="$LANG" locale charmap)" = "UTF-8" ]; then
85209e87 94 run_cmd "Loading keyboard table" loadkeys -u $KEYTABLE < /dev/tty0 > /dev/tty0
db05817e 95 else
85209e87 96 run_cmd "Loading keyboard table" loadkeys $KEYTABLE < /dev/tty0 > /dev/tty0
db05817e 97 fi
25983a1f 98 fi
3f5a48f0 99 run_cmd "Enabling SAK sequence" /bin/sh -c "echo Control Alt keycode 101 = SAK | loadkeys"
25983a1f 100
101 power_option=""
28fc92d2 102 if ! is_no "$POWER_SAVE"; then
25983a1f 103 if [ "$BLANK_TIME" ]; then
104 power_option="-blank $BLANK_TIME";
e277f7c8 105 fi
25983a1f 106 if [ "$POWERDOWN_TIME" ]; then
107 power_option="-powerdown $POWERDOWN_TIME $power_option";
6400d21c 108 fi
43a2fda6 109 else
46342204 110 power_option="-blank 0 -powerdown 0 -powersave off";
25983a1f 111 fi
3e0052a2 112 setterm_option="$power_option"
25983a1f 113 if [ "$FOREGROUND_COLOUR" ]; then
3e0052a2 114 setterm_option="$setterm_option -foreground $FOREGROUND_COLOUR"
25983a1f 115 fi
116 if [ "$BACKGROUND_COLOUR" ]; then
3e0052a2 117 setterm_option="$setterm_option -background $BACKGROUND_COLOUR"
25983a1f 118 fi
833a0c5b 119 if [ "$BEEP_LENGTH" ]; then
3e0052a2 120 setterm_option="$setterm_option -blength $BEEP_LENGTH"
25983a1f 121 fi
f81cfcd9
JB
122 if [ "$BEEP_FREQ" ]; then
123 setterm_option="$setterm_option -bfreq $BEEP_FREQ"
124 fi
3e0052a2 125 setterm_option="$setterm_option -store"
126
127 for cons in $SET_FONT_TERMINALS; do
128 /usr/bin/open -c $cons -s -w -- /usr/bin/setterm $setterm_option
129 done
976efedd
ER
130 if [[ "$tty" = [0-9]* ]]; then
131 /usr/bin/switchto $tty
132 fi
1e62a39e
ER
133
134 touch /var/lock/subsys/console
6069da61
ER
135}
136
2d2e204c 137RETVAL=0
6069da61
ER
138case "$1" in
139 start)
140 if [ ! -f /var/lock/subsys/console ]; then
141 start
6069da61
ER
142 fi
143 ;;
2d2e204c 144 restart)
f81cfcd9 145 start
25983a1f 146 ;;
2d2e204c
JB
147 try-restart)
148 if [ -f /var/lock/subsys/console ]; then
149 start
150 fi
151 ;;
152 reload|force-reload)
153 if [ -f /var/lock/subsys/console ]; then
154 start
155 else
156 RETVAL=7
157 fi
158 ;;
25983a1f 159 stop)
6069da61
ER
160 if [ -f /var/lock/subsys/console ]; then
161 run_cmd "Setting terminals to default values" /usr/bin/setterm -default
162 rm -f /var/lock/subsys/console
163 fi
25983a1f 164 ;;
165 status)
166 /usr/bin/setleds
167 ;;
168 *)
2d2e204c 169 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
5f5274b3 170 exit 3
8a6e015e
AM
171esac
172
2d2e204c 173exit $RETVAL
This page took 0.110541 seconds and 4 git commands to generate.