]> git.pld-linux.org Git - packages/fbset.git/blobdiff - fbset.init
- cosmetics
[packages/fbset.git] / fbset.init
index e951e2aa76284245658361d34cc3acce510eb897..d382c445962d61f6c69b666cb9d050a5406e133b 100644 (file)
@@ -4,13 +4,12 @@
 # fbset:       Sets up fbcon video modes.
 #
 #
-# chkconfig:   2345 5 95
-# description: fbset is a utility with which fbcons video modes can be read
+# chkconfig:   2345 69 31
+# description: fbset is a utility with which fbcons video modes can be read \
 #              and changed
 #
 # config:      /etc/sysconfig/fbset
 
-
 # Source function library
 . /etc/rc.d/init.d/functions
 
@@ -19,61 +18,110 @@ if [ -f /etc/sysconfig/fbset ]; then
        . /etc/sysconfig/fbset
 fi
 
-# See how we were called.
-case "$1" in
-  start)
+function try_load
+{
+       if [ -n "${FBMODULE}" ]; then
+               _modprobe single $FBMODULE
+       else
+               exit 0
+       fi
+}
+
+# Setting default depth
+if [ -n "${DEPTH}" ]; then
+       DEPTH_options="-depth ${DEPTH}"
+fi
+
+if [ -z "${FBDEV_NUM}" ]; then
+       FBDEV_NUM=0
+fi
+
+start() {
        # Check if service is already running?
        if [ ! -f /var/lock/subsys/fbset ]; then
+
                # Check if we have framebuffer in kernel.
                if [ -f /proc/fb ]; then
                        # /proc files show as files with size=0, this is a workaround.
-                       cat /proc/fb | grep -q "." || exit 0
+                       cat /proc/fb | grep -q "." || try_load
                else
-                       exit 0
+                       # if not, then try to load specified kernel module
+                       try_load
                fi
 
                if [ -n "${FBMODE_default}" ]; then
                        show "Setting default video mode"
                        busy
+
                        # check if devfs (workaround: -a option don't work at all)
                        if [ -d /dev/vc ]; then
-                               for a in `ls /dev/vc/*`; do
-                                       b=`ls $a | sed 's/\/dev\/vc\///g'`
-                                       /usr/bin/open -c $b -- /usr/sbin/fbset $FBMODE_default
-                               done
+                               if [ -z "$FBTERMINALS" ]; then
+                                       FBTERMINALS=$(ls /dev/vc/)
+                               fi
+                               FBDEV=/dev/fb/${FBDEV_NUM}
+                               devpath="/dev/vc/"
                        else
-                               for a in `ls /dev/tty[0-9] && ls /dev/tty[0-9][0-9]`; do
-                                       b=`ls $a | sed 's/\/dev\/tty//g'`
-                                       /usr/bin/open -c $b -- /usr/sbin/fbset $FBMODE_default
-                               done
+                               if [ -z "$FBTERMINALS" ]; then
+                                       FBTERMINALS=$(awk -F: '/^[0-9]*:/{print $1}' /etc/inittab)
+                               fi
+                               FBDEV=/dev/fb${FBDEV_NUM}
+                               devpath="/dev/tty"
                        fi
-                       deltext
+
+                       # save old tty number
+                       tty=$(/usr/bin/tty)
+                       tty=${tty#$devpath}
+
+                       for cons in $FBTERMINALS; do
+                               /usr/bin/con2fb $FBDEV $cons
+                               /usr/bin/switchto $cons
+                               /usr/bin/fbset -fb \
+                                 $FBDEV ${DEPTH_options} $FBMODE_default \
+                                 0<>/dev/tty$cons >&0 2>&0
+                       done
+                       [ $tty = "/dev/console" ] && tty=1
+                       /usr/bin/switchto $tty
                        ok
                fi
                touch /var/lock/subsys/fbset
        else
-               msg_Already_Running "fbset"
-               exit 1
+               msg_already_running fbset
+       fi
+}
+
+stop() {
+       if [ -f /var/lock/subsys/fbset ]; then
+               rm -f /var/lock/subsys/fbset
+       else
+               msg_not_running fbset
        fi
+}
+
+# See how we were called.
+case "$1" in
+  start)
+       start
        ;;
-    stop)
-       rm -f /var/lock/subsys/fbset
+  stop)
+       stop
        ;;
   status)
        # Check if we have framebuffer in kernel.
        if [ -f /proc/fb ]; then
                # /proc files show as files with size=0, this is a workaround.
-               cat /proc/fb | grep -q "." || exit 0
-               echo "Frame buffer present."
+               cat /proc/fb | grep -q "." && nls "Frame buffer present." && exit 0
        fi
+
+       nls "Frame buffer not present."
+       exit 3
        ;;
-  restart|reload)
-       $0 stop
-       $0 start
+  restart|force-reload)
+       stop
+       start
        ;;
   *)
-       msg_Usage "$0 {start|stop|status|restart|reload}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       exit 3
 esac
 
 exit 0
This page took 0.080781 seconds and 4 git commands to generate.