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 / acpid < prev    next >
Text File  |  2006-04-22  |  6KB  |  193 lines

  1. #! /bin/bash
  2. # Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany.
  3. # All rights reserved.
  4. #
  5. # Authors: Christian Zoz <zoz@suse.de>
  6. #          Timo Hoenig <thoenig@suse.de>
  7. #
  8. # /etc/init.d/acpid
  9. #   and its symbolic link
  10. # /usr/sbin/rcacpid
  11. #
  12. # LSB compliant service control script; see http://www.linuxbase.org/spec/
  13. ### BEGIN INIT INFO
  14. # Provides:                   acpid
  15. # Required-Start:
  16. # X-UnitedLinux-Should-Start:
  17. # Required-Stop:
  18. # X-UnitedLinux-Should-Stop:
  19. # Default-Start:              2 3 5
  20. # Default-Stop:               0 1 6
  21. # Short-Description: Listen and dispatch ACPI events from the kernel
  22. # Description:       acpid reads events from /proc/acpi/event and dispatches
  23. #    them (by SuSE default) to other "users" like powersaved, HAL and IAL.
  24. #    Actions for those events are (by SUSE default) configured in the
  25. #    powersaved configuration.
  26. #    Additionally this start script loads all needed modules.
  27.  
  28. ### END INIT INFO
  29.  
  30. # Check for missing binaries (stale symlinks should not happen)
  31. ACPID_BIN=/sbin/acpid
  32. test -x $ACPID_BIN || exit 5
  33.  
  34. # Shell functions sourced from /etc/rc.status:
  35. #      rc_check         check and set local and overall rc status
  36. #      rc_status        check and set local and overall rc status
  37. #      rc_status -v     ditto but be verbose in local rc status
  38. #      rc_status -v -r  ditto and clear the local rc status
  39. #      rc_status -s     display "skipped" and exit with status 3
  40. #      rc_status -u     display "unused" and exit with status 3
  41. #      rc_failed        set local and overall rc status to failed
  42. #      rc_failed <num>  set local and overall rc status to <num>
  43. #      rc_reset         clear local rc status (overall remains)
  44. #      rc_exit          exit appropriate to overall rc status
  45. #      rc_active    checks whether a service is activated by symlinks
  46. #      rc_splash arg    sets the boot splash screen to arg (if active)
  47. . /etc/rc.status
  48.  
  49. # Reset status of this service
  50. rc_reset
  51.  
  52. # Return values acc. to LSB for all commands but status:
  53. # 0      - success
  54. # 1       - generic or unspecified error
  55. # 2       - invalid or excess argument(s)
  56. # 3       - unimplemented feature (e.g. "reload")
  57. # 4       - user had insufficient privileges
  58. # 5       - program is not installed
  59. # 6       - program is not configured
  60. # 7       - program is not running
  61. # 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
  62. # Note that starting an already running service, stopping
  63. # or restarting a not-running service as well as the restart
  64. # with force-reload (in case signaling is not supported) are
  65. # considered a success.
  66.  
  67. ACPI_MODULES=""
  68. DEFAULT_ACPI_MODULES="ac battery button fan processor thermal"
  69. ACPI_LAPTOP_MODULES_PROBE="asus_acpi ibm_acpi toshiba_acpi sony_acpi pcc_acpi"
  70. ACPI_LAPTOP_MODULES_FILE="/var/lib/acpi/laptop_modules"
  71.  
  72. ARCH=`uname -i`
  73. case $ARCH in
  74.     ia64)    DEFAULT_ACPI_MODULES="button fan processor thermal"
  75.         ACPI_LAPTOP_MODULES_PROBE=""
  76.         # avoid even occassional probing of laptop modules!
  77.         ACPI_LAPTOP_MODULES_USER="NONE"
  78.         ;;
  79. esac
  80.  
  81. [ -f /etc/sysconfig/powersave/common ] && . /etc/sysconfig/powersave/common
  82. [ -f /etc/sysconfig/acpi ] && . /etc/sysconfig/acpi 
  83.  
  84. case "$1" in
  85.     start)
  86.         if [ ! -d /proc/acpi ] ; then
  87.             echo -n "acpid: no ACPI support in kernel"
  88.             rc_status -s
  89.             rc_exit
  90.         fi
  91.  
  92.         echo -n "acpid: loading ACPI modules ( "
  93.         if [ "$ACPI_MODULES" != "NONE" ]; then
  94.             # load ACPI modules
  95.             for m in ${ACPI_MODULES:-$DEFAULT_ACPI_MODULES}; do
  96.             grep -wq $m /proc/modules || { modprobe -s $m && echo -n "$m " || rc_status; }
  97.             done
  98.         fi
  99.         echo -n ") "
  100.         rc_status -v
  101.  
  102.         if [ -n "$ACPI_LAPTOP_MODULES_USER" ]; then
  103.             if [ "$ACPI_LAPTOP_MODULES_USER" != "NONE" ]; then
  104.             # Load modules defined by user
  105.             for m in ${ACPI_LAPTOP_MODULES_USER}; do
  106.                 grep -wq $m /proc/modules || { modprobe -s $m || rc_status; }
  107.             done
  108.             fi
  109.         else
  110.             if [ /boot/vmlinuz -ot "$ACPI_LAPTOP_MODULES_FILE" ]; then
  111.                 # Load modules defined by system probe
  112.                 while read m; do
  113.                     grep -wq $m /proc/modules || { modprobe -s $m || rc_status; }
  114.                 done < $ACPI_LAPTOP_MODULES_FILE
  115.             else
  116.                 # First run, or kernel has been updated. We have to probe which
  117.             # modules load successfully.
  118.                 echo -n "acpid: probing laptop ACPI modules "
  119.                 touch "$ACPI_LAPTOP_MODULES_FILE"
  120.                 for m in $ACPI_LAPTOP_MODULES_PROBE; do
  121.                     if modprobe -s $m; then
  122.                 # pcc_acpi and sony_acpi can be loaded always. 
  123.                 # remove them if the system does not support them.
  124.                 case $m in
  125.                     sony_acpi)
  126.                     if [ ! -r /proc/acpi/sony/brightness ] ; then
  127.                         rmmod sony_acpi;
  128.                         continue
  129.                     fi ;;
  130.                     pcc_acpi)
  131.                     if [ ! -r /proc/acpi/panasonic ] ; then
  132.                         rmmod pcc_acpi;
  133.                         continue
  134.                     fi ;;
  135.                 esac
  136.                 echo $m >> $ACPI_LAPTOP_MODULES_FILE
  137.                 fi
  138.                 done 
  139.             
  140.                 echo -n;
  141.                 rc_status -v;
  142.             fi
  143.         fi
  144.  
  145.         echo -n "Starting acpid "
  146.         startproc $ACPID_BIN
  147.         rc_status -v
  148.         ;;
  149.     stop)
  150.         echo -n "Shutting down acpid "
  151.         killproc -TERM $ACPID_BIN
  152.         rc_status -v
  153.         ;;
  154.     try-restart)
  155.             $0 status
  156.         if test $? = 0; then
  157.             $0 restart
  158.         else
  159.             rc_reset        # Not running is not a failure.
  160.         fi
  161.         rc_status
  162.         ;;
  163.     restart)
  164.         $0 stop
  165.         $0 start
  166.         rc_status
  167.         ;;
  168.     force-reload|reload)
  169.         echo -n "Reload service acpid "
  170.         killproc -HUP $ACPID_BIN
  171.         rc_status -v
  172.         ;;
  173.     status)
  174.         echo -n "Checking for service acpid "
  175.         PID=`checkproc -v $ACPID_BIN`
  176.         if rc_status ; then
  177.             case `cat /proc/$PID/cmdline` in *events.ignore) rc_failed 3; esac
  178.         fi
  179.         rc_status -v
  180.         ;;
  181.     probe)
  182.         test $ACPID_CONFIG -nt /var/run/acpid.pid && echo restart
  183.         ;;
  184.     *)
  185.         echo "Usage: $0" \
  186.              "{start|stop|status|try-restart|restart|force-reload|reload|probe}"
  187.         exit 1
  188.         ;;
  189. esac
  190. rc_exit
  191.