home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20120521.etc.tar.gz / bradford.20120521.etc.tar / etc / init.d / fbset < prev    next >
Text File  |  2006-04-22  |  5KB  |  203 lines

  1. #! /bin/bash
  2. # Copyright (c) 1995-2003 SuSE Linux AG, Nuernberg, Germany.
  3. #
  4. # Author: Kurt Garloff
  5. #
  6. # /etc/init.d/fbset
  7. #
  8. #   and symbolic its link
  9. #
  10. # /usr/sbin/rcfbset
  11. #
  12. # System startup script for the fb modules and fb configuration
  13. #
  14. ### BEGIN INIT INFO
  15. # Provides: fbset
  16. # Required-Start: $local_fs
  17. # Required-Stop:  $local_fs
  18. # Default-Start:  1 2 3 5
  19. # Default-Stop:   0 6
  20. # Description:    Framebuffer setup
  21. ### END INIT INFO
  22.  
  23. # Source SuSE config
  24. . /etc/sysconfig/console
  25.  
  26. # is anything to do?
  27. test -z "$FB_MODULES" -a -z "$FBSET_PARAMS" && exit 0
  28.  
  29. # check for an already working framebuffer device (for example due to
  30. # a framebuffer driver compiled in kernel)
  31. fbdev_ok=""
  32. if (: < /dev/fb0) 2>/dev/null ; then
  33.   fbdev_ok="1"
  34. fi
  35. # if $FBSET_PARAMS is not empty then $FB_MODULES must be defined or
  36. # framebuffer device must be already working
  37. test -n "$FBSET_PARAMS" && test -z "$fbdev_ok" -a -z "$FB_MODULES" && exit 0
  38.  
  39. FBSET_BIN=/sbin/fbset
  40. # if $FBSET_PARAMS is not empty then $FBSET_BIN must be installed
  41. test -n "$FBSET_PARAMS" -a ! -x $FBSET_BIN && exit 5
  42.  
  43. # Shell functions sourced from /etc/rc.status:
  44. #      rc_check         check and set local and overall rc status
  45. #      rc_status        check and set local and overall rc status
  46. #      rc_status -v     ditto but be verbose in local rc status
  47. #      rc_status -v -r  ditto and clear the local rc status
  48. #      rc_failed        set local and overall rc status to failed
  49. #      rc_failed <num>  set local and overall rc status to <num><num>
  50. #      rc_reset         clear local rc status (overall remains)
  51. #      rc_exit          exit appropriate to overall rc status
  52. . /etc/rc.status
  53.  
  54. # First reset status of this service
  55. rc_reset
  56.  
  57. # Return values acc. to LSB for all commands but status:
  58. # 0 - success
  59. # 1 - generic or unspecified error
  60. # 2 - invalid or excess argument(s)
  61. # 3 - unimplemented feature (e.g. "reload")
  62. # 4 - insufficient privilege
  63. # 5 - program is not installed
  64. # 6 - program is not configured
  65. # 7 - program is not running
  66. # Note that starting an already running service, stopping
  67. # or restarting a not-running service as well as the restart
  68. # with force-reload (in case signalling is not supported) are
  69. # considered a success.
  70.  
  71. case "$1" in
  72.     start)
  73.     echo -n "Framebuffer setup: "
  74.     ## Start daemon with startproc(8). If this fails
  75.     ## the echo return value is set appropriate.
  76.  
  77.      if test ! -z "$FB_MODULES"; then
  78.         # $FB_MODULES needs parsing: It might contain several modules
  79.         # and module parameters. We identify params by the = sign.
  80.         unset mod modpar
  81.         for par in $FB_MODULES; do 
  82.             case $par in
  83.                 *=*) 
  84.                 modpar="$modpar $par"
  85.                 ;;
  86.                 *) 
  87.                 if test ! -z "$mod"; then
  88.                     echo -n "$mod "
  89.                     modprobe $mod $modpar
  90.                     rc_status
  91.                 fi
  92.                 unset modpar
  93.                 mod=$par
  94.                 ;;
  95.             esac
  96.         done
  97.         echo -n "$mod "
  98.         modprobe $mod $modpar
  99.         rc_status
  100.     fi
  101.  
  102.     if test ! -z "$FBSET_PARAMS"; then
  103.         if test -x $FBSET_BIN; then
  104.             mode=`echo $FBSET_PARAMS | sed -e 's/^-[^ ]*//' -e 's/ -[^ ]*//g'`
  105.             echo -n "$mode "
  106.             $FBSET_BIN $FBSET_PARAMS
  107.             rc_status
  108.         else
  109.             echo -n "fbset not installed "
  110.             rc_failed 5
  111.         fi
  112.     fi
  113.  
  114.     # Remember status and be verbose
  115.     rc_status -v
  116.     ;;
  117.     stop)
  118.     # We don't unload the fb driver modules; this could be risky
  119.     # and will probably fail anyway
  120.     ;;
  121.     try-restart)
  122.     ## Stop the service and if this succeeds (i.e. the 
  123.     ## service was running before), start it again.
  124.     ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
  125.     $0 status >/dev/null &&  $0 restart
  126.  
  127.     # Remember status and be quiet
  128.     rc_status
  129.     ;;
  130.     restart)
  131.     ## Stop the service and regardless of whether it was
  132.     ## running or not, start it again.
  133.     $0 start
  134.  
  135.     # Remember status and be quiet
  136.     rc_status
  137.     ;;
  138.     force-reload)
  139.     ## Signal the daemon to reload its config. Most daemons
  140.     ## do this on signal 1 (SIGHUP).
  141.     ## If it does not support it, restart.
  142.     $0 try-restart
  143.     rc_status
  144.     ;;
  145.     reload)
  146.     $0 try-restart
  147.     rc_status
  148.     ;;
  149.     status)
  150.     echo -n "Checking for framebuffer setup: "
  151.     ## Check status with checkproc(8), if process is running
  152.     ## checkproc will return with exit status 0.
  153.  
  154.     # Status has a slightly different for the status command:
  155.     # 0 - service running
  156.     # 1 - service dead, but /var/run/  pid  file exists
  157.     # 2 - service dead, but /var/lock/ lock file exists
  158.     # 3 - service not running
  159.     
  160.     if test ! -z "$FB_MODULES"; then
  161.         # $FB_MODULES needs parsing: It might contain several modules
  162.         # and module parameters. We identify params by the = sign.
  163.         for par in $FB_MODULES; do
  164.             case $par in
  165.                 *=*) 
  166.                 ;;
  167.                 *) 
  168.                 if test ! -z "$par"; then
  169.                     if test -z "`lsmod | grep $par`";
  170.                         then echo -n '!'"$par "
  171.                         rc_failed 3
  172.                     else
  173.                         echo -n "$par "
  174.                     fi
  175.                 fi
  176.                 ;;
  177.             esac
  178.         done
  179.     fi
  180.     
  181.     if test -x $FBSET_BIN; then
  182.         mode=`$FBSET_BIN | grep -e "^mode" | sed 's/[^"]*"\([^"]*\)".*/\1/'`
  183.         rc_status
  184.         echo -n "$mode "
  185.     fi
  186.         
  187.     rc_status -v
  188.     ;;
  189.     probe)
  190.     ## Optional: Probe for the necessity of a reload,
  191.     ## give out the argument which is required for a reload.
  192.     test -r /proc/uptime -a -x /bin/date -a ! -z "$FBSET_PARAMS" -a -x $FBSET_BIN || exit 0
  193.     boottm=$[`date -u +%s`-`cat /proc/uptime|sed 's/\([^\.]*\).*/\1/'`]
  194.     test $boottm -lt `date -r /etc/fb.modes -u +%s` -o $boottm -lt `date -r $FBSET_BIN -u +%s` && echo reload
  195.     ;;
  196.     *)
  197.     echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
  198.     exit 1
  199.     ;;
  200. esac
  201. rc_exit
  202.