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.20120305.etc.tar.gz / bradford.20120305.etc.tar / etc / init.d / lm_sensors < prev    next >
Text File  |  2006-05-02  |  3KB  |  146 lines

  1. #!/bin/sh
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides:       sensors
  5. # Required-Start: $remote_fs
  6. # Required-Stop:  $remote_fs
  7. # Default-Start:  2 3 5
  8. # Default-Stop:
  9. # Description:    sensors is used for monitoring motherboard sensor values.
  10. #                 Config file is /etc/sysconfig/lm_sensors
  11. ### END INIT INFO
  12. #
  13. #    This program is free software; you can redistribute it and/or modify
  14. #    it under the terms of the GNU General Public License as published by
  15. #    the Free Software Foundation; either version 2 of the License, or
  16. #    (at your option) any later version.
  17. #
  18. #    This program is distributed in the hope that it will be useful,
  19. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. #    GNU General Public License for more details.
  22. #
  23. #    You should have received a copy of the GNU General Public License
  24. #    along with this program; if not, write to the Free Software
  25. #    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. # See also the lm_sensors homepage at:
  28. #     http://www2.lm-sensors.nu/~lm78/index.html
  29.  
  30. # It uses a config file /etc/sysconfig/sensors that contains the modules to
  31. # be loaded/unloaded. That file is sourced into this one.
  32.  
  33. # The format of that file a shell script that simply defines the modules 
  34. # in order as normal shell variables with the special names:
  35. #    MODULE_1, MODULE_2, MODULE_3, etc.
  36.  
  37. # If sensors isn't supported by the kernel, try loading the module...
  38. [ -e /sys/bus/i2c/devices ] || /sbin/modprobe i2c-sensor &>/dev/null
  39.  
  40. # Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
  41. # support for sensors.
  42. [ -e /sys/bus/i2c/devices ] || exit 0
  43.   
  44. # If sensors was not already running, unload the module...
  45. [ -e /var/lock/subsys/sensors ] || /sbin/modprobe -r i2c-sensor &>/dev/null
  46.  
  47. CONFIG=/etc/sysconfig/lm_sensors
  48. PSENSORS=/usr/bin/sensors
  49. FANCONFIG=/etc/fancontrol
  50. PFAN=/usr/sbin/fancontrol
  51.  
  52. # Source function library.
  53. . /etc/rc.status
  54.  
  55. start() {
  56.     echo -n "Starting up sensors"
  57.     unset ${!MODULE_*}
  58.     test -r "$CONFIG" && . "$CONFIG"
  59.  
  60.     for i in ${!MODULE_*} ; do
  61.         eval module=\$$i
  62.         /sbin/modprobe $module &>/dev/null
  63.         rc_status
  64.     done
  65.     rc_status
  66.  
  67.     /usr/bin/sensors -s &> /dev/null
  68.     rc_status
  69.  
  70.     # Start fan control, if configured
  71.     if test -s "$FANCONFIG" -a -x "$PFAN" ; then
  72.         echo -n ", starting fan control: "
  73.         /sbin/startproc -q "$PFAN"
  74.         rc_status
  75.     else
  76.         echo -n ": "
  77.     fi
  78.  
  79.     rc_status -v && touch /var/lock/subsys/sensors
  80. }
  81.  
  82. stop() {
  83.     echo -n "Shutting down sensors"
  84.     unset ${!MODULE_*}
  85.     test -r "$CONFIG" && . "$CONFIG"
  86.  
  87.     # Stop fan control, if it was started
  88.     if test -s /var/run/fancontrol.pid ; then
  89.         echo -n ", stopping fan control: "
  90.         /sbin/killproc -TERM "$PFAN"
  91.         rc_status
  92.     else
  93.         echo -n ": "
  94.     fi
  95.  
  96.     for i in ${!MODULE_*} ; do
  97.         eval module=\$$i
  98.         /sbin/modprobe -r $module &>/dev/null
  99.         rc_status
  100.     done
  101.  
  102.     rc_status -v && rm -f /var/lock/subsys/sensors
  103. }
  104.  
  105. dostatus() {
  106.     $PSENSORS
  107.     rc_status
  108. }
  109.  
  110. restart() {
  111.     stop
  112.     start
  113.     rc_status
  114. }
  115.  
  116. condrestart() {
  117.     [ -e /var/lock/subsys/lm_sensors ] && restart || :
  118. }
  119.  
  120. # Reset status of this service
  121. rc_reset
  122.  
  123. # See how we were called.
  124. case "$1" in
  125.   start)
  126.     start
  127.     ;;
  128.   stop)
  129.     stop
  130.     ;;
  131.   status)
  132.     dostatus
  133.     ;;
  134.   restart|reload)
  135.     restart
  136.     ;;
  137.   try-restart)
  138.     condrestart
  139.     ;;
  140.   *)
  141.     echo "Usage: lm_sensors {start|stop|status|restart|reload|try-restart}"
  142.     exit 1
  143. esac
  144.  
  145. rc_exit
  146.