]> git.pld-linux.org Git - packages/kbd.git/blob - kbd.init
- set font on all consoles via open
[packages/kbd.git] / kbd.init
1 #!/bin/sh
2
3 # console       Loads console font and keyboard table
4 #
5 # chkconfig:    345 70 30
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.
11 # This means, if /usr is NFS-mounted it needs to
12 # be run after networking and NFS mounts are up.
13
14 [ -f /etc/sysconfig/console ] || exit 0
15
16 [ -f /bin/loadkeys -o -f /usr/bin/loadkeys ] || exit 0
17 [ -f /bin/setfont -o -f /usr/bin/setfont ] || exit 0
18
19 [ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
20
21 # Source function library
22 . /etc/rc.d/init.d/functions
23
24 if is_yes "$VSERVER"; then
25         exit 0
26 fi
27
28 . /etc/sysconfig/console
29
30 start() {
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
40
41         # Check for devfs (workaround: -a option doesn't work at all)
42         if [ -d /dev/vc ]; then
43                 devpath="/dev/vc/"
44         else
45                 devpath="/dev/tty"
46         fi
47         # save old tty number
48         tty=$(/usr/bin/tty)
49         tty=${tty#$devpath}
50         if [ "$tty" = "/dev/console" ]; then
51                 tty=1
52         fi
53
54         if [ -n "$CONSOLEFONT" -a -x /sbin/setsysfont ]; then
55                 show "Loading console font and map"
56                 busy
57
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
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
68                         fi
69
70                         for cons in $SET_FONT_TERMINALS; do
71                                 /usr/bin/open -c $cons -s -w -- /sbin/setsysfont
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
78                                 fi
79                         done
80
81                         if [[ "$tty" = [0-9]* ]]; then
82                                 /usr/bin/switchto $tty
83                         fi
84                 else
85                         for cons in $SET_FONT_TERMINALS; do
86                                 /usr/bin/open -c $cons -s -w -- /sbin/setsysfont
87                         done
88                 fi
89                 ok
90         fi
91
92         if [ -n "$KEYTABLE" ]; then
93                 case "$LANG" in
94                 *.utf8|*.UTF-8)
95                         run_cmd "Loading keyboard table" loadkeys -u $KEYTABLE < /dev/tty0 > /dev/tty0
96                         ;;
97                 *)
98                         run_cmd "Loading keyboard table" loadkeys $KEYTABLE < /dev/tty0 > /dev/tty0
99                 esac
100         fi
101         run_cmd "Enabling SAK sequence" /bin/sh -c "echo Control Alt keycode 101 = SAK | loadkeys"
102
103         power_option=""
104         if [ "$POWER_SAVE" ]; then
105                 if [ "$BLANK_TIME" ]; then
106                         power_option="-blank $BLANK_TIME";
107                 fi
108                 if [ "$POWERDOWN_TIME" ]; then
109                         power_option="-powerdown $POWERDOWN_TIME $power_option";
110                 fi
111         fi
112         setterm_option="$power_option"
113         if [ "$FOREGROUND_COLOUR" ]; then
114                 setterm_option="$setterm_option -foreground $FOREGROUND_COLOUR"
115         fi
116         if [ "$BACKGROUND_COLOUR" ]; then
117                 setterm_option="$setterm_option -background $BACKGROUND_COLOUR"
118         fi
119         if [ "$BEEP_LENGTH" ]; then
120                 setterm_option="$setterm_option -blength $BEEP_LENGTH"
121         fi
122         setterm_option="$setterm_option -store"
123
124         for cons in $SET_FONT_TERMINALS; do
125                 /usr/bin/open -c $cons -s -w -- /usr/bin/setterm $setterm_option
126         done
127         if [[ "$tty" = [0-9]* ]]; then
128                 /usr/bin/switchto $tty
129         fi
130
131         touch /var/lock/subsys/console
132 }
133
134 case "$1" in
135   start)
136         if [ ! -f /var/lock/subsys/console ]; then
137                 start
138         fi
139         ;;
140   restart|reload|force-reload)
141         start
142         ;;
143   stop)
144         if [ -f /var/lock/subsys/console ]; then
145                 run_cmd "Setting terminals to default values" /usr/bin/setterm -default
146                 rm -f /var/lock/subsys/console
147         fi
148         ;;
149   status)
150         /usr/bin/setleds
151         ;;
152   *)
153         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
154         exit 3
155 esac
156
157 exit 0
This page took 0.237471 seconds and 4 git commands to generate.