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