]> git.pld-linux.org Git - packages/lm_sensors.git/blob - sensors_modules.init
07c12e0b72b872acaea5f4e4a500d12d1ffda4ea
[packages/lm_sensors.git] / sensors_modules.init
1 #!/bin/sh
2 #
3 # sensors_modules:      Hardware sensors monitoring
4 #
5 # Version:      $Revision$
6 #
7 # chkconfig:    2345 31 69
8 # description:  Loads and removes hardware sensors modules
9
10 # Source function library.
11 . /etc/rc.d/init.d/functions
12
13 # Get service config
14 if [ -f /etc/sysconfig/sensors_modules ]; then
15         . /etc/sysconfig/sensors_modules
16 fi
17
18 start() {
19         # Check if the service is already running?
20         if [ ! -f /var/lock/subsys/sensors_modules ]; then
21                 if [ -z "$BUS" ] && [ -z "$CHIP" ]; then
22                         msg_starting "sensors modules"; fail
23                         nls "BUS or CHIP not configured in /etc/sysconfig/sensors_modules" >&2
24                         exit 6
25                 fi
26
27                 # insert modules
28                 for i in $BUS; do
29                         _modprobe single die "i2c-$i"
30                 done
31                 for i in $CHIP; do
32                         _modprobe single die "$i"
33                 done
34
35                 if [ "$SENSORS_SET" = "1" ]; then
36                         sensors -s
37                 fi
38                 touch /var/lock/subsys/sensors_modules
39         else
40                 msg_already_running "sensors modules"
41         fi
42 }
43
44 stop() {
45         if [ -f /var/lock/subsys/sensors_modules ]; then
46                 msg_stopping "sensors modules"
47
48                 # remove kernel modules
49                 for i in $CHIP; do
50                         /sbin/rmmod $i >/dev/null 2>&1
51                 done
52                 for i in $BUS; do
53                         /sbin/rmmod i2c-$BUS >/dev/null 2>&1
54                 done
55                 ok
56                 rm -f /var/lock/subsys/sensors_modules
57         else
58                 msg_not_running "sensors modules"
59         fi
60 }
61
62 RETVAL=0
63 # See how we were called.
64 case "$1" in
65   start)
66         start
67         ;;
68   stop)
69         stop
70         ;;
71   status)
72         sensors
73         ;;
74   restart|force-reload)
75         stop
76         start
77         ;;
78   *)
79         msg_usage "$0 {start|stop|restart|force-reload|status}"
80         exit 3
81 esac
82
83 exit $RETVAL
This page took 0.051828 seconds and 2 git commands to generate.