root/lm-sensors/trunk/prog/init/lm_sensors.init @ 1414

Revision 1414, 2.9 KB (checked in by mds, 11 years ago)

Redhat init scripts from

mike808 <mike808@…>

README by mds w/ info from mike.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/sh
2#
3# chkconfig: 2345 26 74
4# description: sensors is used for monitoring motherboard sensor values.
5# config: /etc/sysconfig/sensors
6#
7#    This program is free software; you can redistribute it and/or modify
8#    it under the terms of the GNU General Public License as published by
9#    the Free Software Foundation; either version 2 of the License, or
10#    (at your option) any later version.
11#
12#    This program is distributed in the hope that it will be useful,
13#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#    GNU General Public License for more details.
16#
17#    You should have received a copy of the GNU General Public License
18#    along with this program; if not, write to the Free Software
19#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21# See also the lm_sensors homepage at:
22#     http://www2.lm-sensors.nu/~lm78/index.html
23
24# It uses a config file /etc/sysconfig/sensors that contains the modules to
25# be loaded/unloaded. That file is sourced into this one.
26
27# The format of that file a shell script that simply defines the modules
28# in order as normal shell variables with the special names:
29#    MODULE_1, MODULE_2, MODULE_3, etc.
30
31# If sensors isn't supported by the kernel, try loading the module...
32[ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc &>/dev/null
33
34# Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
35# support for sensors.
36[ -e /proc/sys/dev/sensors ] || exit 0
37
38# If sensors was not already running, unload the module...
39[ -e /var/lock/subsys/sensors ] || /sbin/modprobe -r i2c-proc &>/dev/null
40
41CONFIG=/etc/sysconfig/lm_sensors
42
43# Source function library.
44. /etc/init.d/functions
45
46RETVAL=0
47
48start() {
49        echo -n $"Starting up sensors: "
50        test -r "$CONFIG" && . "$CONFIG"
51
52        modules=`grep \^MODULE_ $CONFIG | wc -l`
53        i=0
54        while [ $i -lt $modules ] ; do
55                module=`eval echo '$'MODULE_$i`
56                /sbin/modprobe $module &>/dev/null
57                i=`expr $i + 1`
58        done
59
60        RETVAL=$?
61        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sensors
62        echo
63}
64
65stop() {
66        echo -n $"Shutting down sensors: "
67        test -r "$CONFIG" && . "$CONFIG"
68
69        modules=`grep \^MODULE_ $CONFIG | wc -l`
70        i=$modules
71        while [ $i -ge 0 ] ; do
72                module=`eval echo '$'MODULE_$i`
73                /sbin/modprobe -r $module &>/dev/null
74                i=`expr $i - 1`
75        done
76        /sbin/modprobe -r i2c-proc &>/dev/null
77
78        RETVAL=$?
79        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sensors
80        echo
81}
82
83dostatus() {
84        /usr/bin/sensors
85        RETVAL=$?
86}
87
88restart() {
89        stop
90        start
91        RETVAL=$?
92}
93
94condrestart() {
95        [ -e /var/lock/subsys/sensors ] && restart || :
96}
97
98# See how we were called.
99case "$1" in
100  start)
101        start
102        ;;
103  stop)
104        stop
105        ;;
106  status)
107        dostatus
108        ;;
109  restart|reload)
110        restart
111        ;;
112  condrestart)
113        condrestart
114        ;;
115  *)
116        echo "Usage: sensors.init {start|stop|status|restart|reload|condrestart}"
117        exit 1
118esac
119
120exit $RETVAL
Note: See TracBrowser for help on using the browser.