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