]> git.pld-linux.org Git - packages/lm_sensors.git/blob - fancontrol.init
- isadump/isaset also on x32
[packages/lm_sensors.git] / fancontrol.init
1 #!/bin/sh
2 #
3 # fancontrol    Fans speed control according to temperature service
4 #
5 # Starts after all hotplug-like things, which could load proper drivers
6 # for fans and dies last possible
7 # chkconfig:    345 09 99
8 #
9 # description:  It is crucial to proper configure this service, or severe
10 #               damadge could occur. For this, be sure, to run init first
11 #               and be sure the configuration is correct.
12 #
13 # TODO:
14 # - check this, case this is my first 'advanced' init script
15 # - maybe add some more stop control, like re-running fancontrol and killing
16 #   it once more, if killproc fails
17 #
18
19 # Source function library
20 . /etc/rc.d/init.d/functions
21
22 # Get service config
23  [ -f /etc/sysconfig/fancontrol ] && . /etc/sysconfig/fancontrol
24
25 start() {
26         # sensors deamon needs to be started
27         # or at least proper modules loaded (provided by sensorsd deamon)
28         if [ ! -f /var/lock/subsys/sensord ]; then
29                 echo "Start sensors daemon first"
30                 RETVAL=1
31                 return
32         fi
33
34         # Check if the service is already running?
35         if [ -f /var/lock/subsys/fancontrol ]; then
36                 msg_already_running fancontrol
37                 return
38         fi
39
40         # Fancontrol needs to check system for pwm control
41         if [ ! -f /etc/sysconfig/fancontrol ]; then
42                 nls "Fancontrol not initialized."
43                 nls "Try \`%s init' before start." "$0"
44                 exit 6
45         fi
46
47         msg_starting fancontrol
48         # won't start without an output
49         daemon --fork --redirfds /usr/sbin/fancontrol
50         RETVAL=$?
51         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fancontrol
52 }
53
54 stop() {
55         if [ ! -f /var/lock/subsys/fancontrol ]; then
56                 msg_not_running fancontrol
57                 return
58         fi
59
60         # Stop daemons.
61         msg_stopping fancontrol
62         # it's crucial to be sure it ended ok, otherwise we get
63         # the fans set and the computer working without any control
64         # and that could cause MASSIVE damage
65         killproc --waitforname fancontrol --waitfortime 30 fancontrol -TERM
66         rm -f /var/lock/subsys/fancontrol
67 }
68
69 restart() {
70         stop
71         start
72 }
73
74 # See how we were called.
75 case "$1" in
76   start)
77         start
78         ;;
79   stop)
80         stop
81         ;;
82   restart)
83         restart
84         ;;
85   init)
86         pwmconfig
87         exit $?
88         ;;
89   status)
90         status fancontrol
91         RETVAL=$?
92         ;;
93   *)
94         msg_usage "$0 {start|stop|restart|init|status}"
95         exit 3
96 esac
97
98 exit $RETVAL
This page took 0.08712 seconds and 3 git commands to generate.