root/lm-sensors/branches/lm-sensors-3.0.0/prog/init/lm_sensors.init.suse @ 4379

Revision 4379, 4.9 KB (checked in by khali, 8 years ago)

init scripts:
* Delete sample lm_sensors.sysconfig file, it is now generated by

sensors-detect.

* Fix several occurences of the configuration file name.

  • 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### BEGIN INIT INFO
4# Provides:                     lm_sensors
5# Required-Start:               $local_fs
6# X-UnitedLinux-Should-Start:   
7# Required-Stop:                $local_fs
8# X-UnitedLinux-Should-Stop:   
9# Default-Start:                3 4 5
10# Default-Stop:                 0 1 2 6
11# Short-Description:            LM Sensors
12# Description:                  LM Sensors for hardware monitoring
13### END INIT INFO
14# chkconfig: 2345 26 74
15# description: sensors is used for monitoring motherboard sensor values.
16# config: /etc/sysconfig/lm_sensors
17#
18#    This program is free software; you can redistribute it and/or modify
19#    it under the terms of the GNU General Public License as published by
20#    the Free Software Foundation; either version 2 of the License, or
21#    (at your option) any later version.
22#
23#    This program is distributed in the hope that it will be useful,
24#    but WITHOUT ANY WARRANTY; without even the implied warranty of
25#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26#    GNU General Public License for more details.
27#
28#    You should have received a copy of the GNU General Public License
29#    along with this program; if not, write to the Free Software
30#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31
32# See also the lm_sensors homepage at:
33#     http://www.lm-sensors.org
34
35# It uses a config file /etc/sysconfig/lm_sensors that contains the modules
36# to be loaded/unloaded. That file is sourced into this one.
37
38# The format of that file a shell script that simply defines the modules
39# in order as normal shell variables with the special names:
40#    MODULE_1, MODULE_2, MODULE_3, etc.
41
42# If sensors isn't supported by the kernel, try loading the module...
43[ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc &>/dev/null
44
45# Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
46# support for sensors.
47[ -e /proc/sys/dev/sensors ] || exit 0
48
49# If sensors was not already running, unload the module...
50[ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc &>/dev/null
51
52CONFIG=/etc/sysconfig/lm_sensors
53PSENSORS=/usr/local/bin/sensors
54
55# Source function library.
56#. /etc/init.d/functions
57
58# Shell functions sourced from /etc/rc.status:
59#      rc_check         check and set local and overall rc status
60#      rc_status        check and set local and overall rc status
61#      rc_status -v     ditto but be verbose in local rc status
62#      rc_status -v -r  ditto and clear the local rc status
63#      rc_status -s     display "skipped" and exit with status 3
64#      rc_status -u     display "unused" and exit with status 3
65#      rc_failed        set local and overall rc status to failed
66#      rc_failed <num>  set local and overall rc status to <num>
67#      rc_reset         clear local rc status (overall remains)
68#      rc_exit          exit appropriate to overall rc status
69#      rc_active        checks whether a service is activated by symlinks
70#      rc_splash arg    sets the boot splash screen to arg (if active)
71. /etc/rc.status
72
73# Reset status of this service
74rc_reset
75
76# Return values acc. to LSB for all commands but status:
77# 0       - success
78# 1       - generic or unspecified error
79# 2       - invalid or excess argument(s)
80# 3       - unimplemented feature (e.g. "reload")
81# 4       - user had insufficient privileges
82# 5       - program is not installed
83# 6       - program is not configured
84# 7       - program is not running
85# 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
86#
87# Note that starting an already running service, stopping
88# or restarting a not-running service as well as the restart
89# with force-reload (in case signaling is not supported) are
90# considered a success.
91
92RETVAL=0
93
94start() {
95        echo -n $"Starting up sensors: "
96        test -r "$CONFIG" && . "$CONFIG"
97
98        modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
99        i=0
100        while [ $i -lt $modules ] ; do
101                module=`eval echo '$'MODULE_$i`
102                echo starting module __${module}__
103                /sbin/modprobe $module &>/dev/null
104                i=`expr $i + 1`
105        done
106        $PSENSORS -s
107
108        RETVAL=$?
109        if [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lm_sensors ; then
110            rc_status -v
111        else
112            rc_status -v
113        fi
114}
115
116stop() {
117        echo -n $"Shutting down sensors: "
118        test -r "$CONFIG" && . "$CONFIG"
119
120        modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
121        i=`expr $modules`
122        while [ $i -ge 0 ] ; do
123                module=`eval echo '$'MODULE_$i`
124                /sbin/modprobe -r $module &>/dev/null
125                i=`expr $i - 1`
126        done
127        /sbin/modprobe -r i2c-proc &>/dev/null
128
129        RETVAL=$?
130        if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/lm_sensors ; then
131            rc_status -v
132        else
133            rc_status -v
134        fi
135}
136
137dostatus() {
138        $PSENSORS
139        RETVAL=$?
140}
141
142restart() {
143        stop
144        start
145        RETVAL=$?
146}
147
148condrestart() {
149        [ -e /var/lock/subsys/lm_sensors ] && restart || :
150}
151
152# See how we were called.
153case "$1" in
154  start)
155        start
156        ;;
157  stop)
158        stop
159        ;;
160  status)
161        dostatus
162        ;;
163  restart|reload)
164        restart
165        ;;
166  condrestart)
167        condrestart
168        ;;
169  *)
170        echo "Usage: sensors.init {start|stop|status|restart|reload|condrestart}"
171        exit 1
172esac
173
174exit $RETVAL
Note: See TracBrowser for help on using the browser.