]> git.pld-linux.org Git - packages/fbset.git/blob - fbset.init
- cosmetics
[packages/fbset.git] / fbset.init
1 #!/bin/sh
2 # $Id$
3 #
4 # fbset:        Sets up fbcon video modes.
5 #
6 #
7 # chkconfig:    2345 69 31
8 # description:  fbset is a utility with which fbcons video modes can be read \
9 #               and changed
10 #
11 # config:       /etc/sysconfig/fbset
12
13 # Source function library
14 . /etc/rc.d/init.d/functions
15
16 # Get service config
17 if [ -f /etc/sysconfig/fbset ]; then
18         . /etc/sysconfig/fbset
19 fi
20
21 function try_load
22 {
23         if [ -n "${FBMODULE}" ]; then
24                 _modprobe single $FBMODULE
25         else
26                 exit 0
27         fi
28 }
29
30 # Setting default depth
31 if [ -n "${DEPTH}" ]; then
32         DEPTH_options="-depth ${DEPTH}"
33 fi
34
35 if [ -z "${FBDEV_NUM}" ]; then
36         FBDEV_NUM=0
37 fi
38
39 start() {
40         # Check if service is already running?
41         if [ ! -f /var/lock/subsys/fbset ]; then
42
43                 # Check if we have framebuffer in kernel.
44                 if [ -f /proc/fb ]; then
45                         # /proc files show as files with size=0, this is a workaround.
46                         cat /proc/fb | grep -q "." || try_load
47                 else
48                         # if not, then try to load specified kernel module
49                         try_load
50                 fi
51
52                 if [ -n "${FBMODE_default}" ]; then
53                         show "Setting default video mode"
54                         busy
55
56                         # check if devfs (workaround: -a option don't work at all)
57                         if [ -d /dev/vc ]; then
58                                 if [ -z "$FBTERMINALS" ]; then
59                                         FBTERMINALS=$(ls /dev/vc/)
60                                 fi
61                                 FBDEV=/dev/fb/${FBDEV_NUM}
62                                 devpath="/dev/vc/"
63                         else
64                                 if [ -z "$FBTERMINALS" ]; then
65                                         FBTERMINALS=$(awk -F: '/^[0-9]*:/{print $1}' /etc/inittab)
66                                 fi
67                                 FBDEV=/dev/fb${FBDEV_NUM}
68                                 devpath="/dev/tty"
69                         fi
70
71                         # save old tty number
72                         tty=$(/usr/bin/tty)
73                         tty=${tty#$devpath}
74
75                         for cons in $FBTERMINALS; do
76                                 /usr/bin/con2fb $FBDEV $cons
77                                 /usr/bin/switchto $cons
78                                 /usr/bin/fbset -fb \
79                                   $FBDEV ${DEPTH_options} $FBMODE_default \
80                                   0<>/dev/tty$cons >&0 2>&0
81                         done
82                         [ $tty = "/dev/console" ] && tty=1
83                         /usr/bin/switchto $tty
84                         ok
85                 fi
86                 touch /var/lock/subsys/fbset
87         else
88                 msg_already_running fbset
89         fi
90 }
91
92 stop() {
93         if [ -f /var/lock/subsys/fbset ]; then
94                 rm -f /var/lock/subsys/fbset
95         else
96                 msg_not_running fbset
97         fi
98 }
99
100 # See how we were called.
101 case "$1" in
102   start)
103         start
104         ;;
105   stop)
106         stop
107         ;;
108   status)
109         # Check if we have framebuffer in kernel.
110         if [ -f /proc/fb ]; then
111                 # /proc files show as files with size=0, this is a workaround.
112                 cat /proc/fb | grep -q "." && nls "Frame buffer present." && exit 0
113         fi
114
115         nls "Frame buffer not present."
116         exit 3
117         ;;
118   restart|force-reload)
119         stop
120         start
121         ;;
122   *)
123         msg_usage "$0 {start|stop|restart|force-reload|status}"
124         exit 3
125 esac
126
127 exit 0
This page took 0.0341 seconds and 3 git commands to generate.