]>
Commit | Line | Data |
---|---|---|
8a6e015e | 1 | #!/bin/sh |
7c0a328f TP |
2 | |
3 | # console Loads console font and keyboard table | |
8a6e015e | 4 | # |
6b4f8129 | 5 | # chkconfig: 345 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 |
24 | if is_yes "$VSERVER"; then |
25 | exit 0 | |
26 | fi | |
27 | ||
6069da61 | 28 | . /etc/sysconfig/console |
8a6e015e | 29 | |
6069da61 | 30 | start() { |
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 AM |
54 | if [ -n "$CONSOLEFONT" -a -x /sbin/setsysfont ]; then |
55 | CMD="/sbin/setsysfont" | |
25983a1f | 56 | show "Loading console font and map" |
57 | busy | |
58 | ||
154b5c25 AM |
59 | # don't initialize on multiple terminals if we use fbset |
60 | # (assume that, in this case fb is loaded as a module) | |
61 | if [ ! -z "$FB" ]; then | |
25983a1f | 62 | |
3e0052a2 | 63 | # check if devfs (workaround: -a option doesn't work at all) |
154b5c25 | 64 | if [ -d /dev/vc ]; then |
1e62a39e | 65 | DEVICES=$(ls /dev/vc/) |
154b5c25 | 66 | else |
1e62a39e | 67 | DEVICES=$(awk -F: '/^[0-9]*:/{print $1}' /etc/inittab) |
154b5c25 | 68 | fi |
25983a1f | 69 | |
154b5c25 | 70 | [ -z "$SET_FONT_TERMINALS" ] && SET_FONT_TERMINALS="$DEVICES" |
25983a1f | 71 | |
154b5c25 AM |
72 | for cons in $SET_FONT_TERMINALS; do |
73 | /usr/bin/open -c $cons -s -w -- $CMD | |
74 | if [ "$NUM_LOCK" ]; then | |
75 | if [ $NUM_LOCK = "on" ]; then | |
76 | /usr/bin/open -c $cons -s -w -- /usr/bin/setleds -D +num | |
77 | else | |
78 | /usr/bin/open -c $cons -s -w -- /usr/bin/setleds -D -num | |
79 | fi | |
55dbdd10 | 80 | fi |
154b5c25 | 81 | done |
e277f7c8 | 82 | |
25983a1f | 83 | /usr/bin/switchto $tty |
84 | else | |
6069da61 | 85 | $CMD |
e277f7c8 | 86 | fi |
25983a1f | 87 | ok |
88 | fi | |
85209e87 | 89 | |
25983a1f | 90 | if [ -n "$KEYTABLE" ]; then |
85209e87 PS |
91 | case "$LANG" in |
92 | *.utf8|*.UTF-8) | |
93 | run_cmd "Loading keyboard table" loadkeys -u $KEYTABLE < /dev/tty0 > /dev/tty0 | |
94 | ;; | |
95 | *) | |
96 | run_cmd "Loading keyboard table" loadkeys $KEYTABLE < /dev/tty0 > /dev/tty0 | |
97 | esac | |
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="" | |
102 | if [ "$POWER_SAVE" ]; then | |
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 |
25983a1f | 109 | fi |
3e0052a2 | 110 | setterm_option="$power_option" |
25983a1f | 111 | if [ "$FOREGROUND_COLOUR" ]; then |
3e0052a2 | 112 | setterm_option="$setterm_option -foreground $FOREGROUND_COLOUR" |
25983a1f | 113 | fi |
114 | if [ "$BACKGROUND_COLOUR" ]; then | |
3e0052a2 | 115 | setterm_option="$setterm_option -background $BACKGROUND_COLOUR" |
25983a1f | 116 | fi |
833a0c5b | 117 | if [ "$BEEP_LENGTH" ]; then |
3e0052a2 | 118 | setterm_option="$setterm_option -blength $BEEP_LENGTH" |
25983a1f | 119 | fi |
3e0052a2 | 120 | setterm_option="$setterm_option -store" |
121 | ||
122 | for cons in $SET_FONT_TERMINALS; do | |
123 | /usr/bin/open -c $cons -s -w -- /usr/bin/setterm $setterm_option | |
124 | done | |
125 | /usr/bin/switchto $tty | |
1e62a39e ER |
126 | |
127 | touch /var/lock/subsys/console | |
6069da61 ER |
128 | } |
129 | ||
130 | case "$1" in | |
131 | start) | |
132 | if [ ! -f /var/lock/subsys/console ]; then | |
133 | start | |
6069da61 ER |
134 | fi |
135 | ;; | |
136 | restart|reload|force-reload) | |
137 | start | |
25983a1f | 138 | ;; |
139 | stop) | |
6069da61 ER |
140 | if [ -f /var/lock/subsys/console ]; then |
141 | run_cmd "Setting terminals to default values" /usr/bin/setterm -default | |
142 | rm -f /var/lock/subsys/console | |
143 | fi | |
25983a1f | 144 | ;; |
145 | status) | |
146 | /usr/bin/setleds | |
147 | ;; | |
148 | *) | |
5f5274b3 | 149 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
150 | exit 3 | |
8a6e015e AM |
151 | esac |
152 | ||
153 | exit 0 |