]> git.pld-linux.org Git - packages/lm_sensors.git/blame_incremental - fancontrol.init
- use functions
[packages/lm_sensors.git] / fancontrol.init
... / ...
CommitLineData
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# $Id$
14#
15# TODO:
16# - check this, case this is my first 'advanced' init script
17# - maybe add some more stop control, like re-running fancontrol and killing
18# it once more, if killproc fails
19#
20
21# Source function library
22. /etc/rc.d/init.d/functions
23
24# Get service config
25 [ -f /etc/sysconfig/fancontrol ] && . /etc/sysconfig/fancontrol
26
27start() {
28 # sensors deamon needs to be started
29 # or at least proper modules loaded (provided by sensorsd deamon)
30 if [ -f /var/lock/subsys/sensors ]; then
31 # Check if the service is already running?
32 if [ ! -f /var/lock/subsys/fancontrol ]; then
33 # Fancontrol needs to check system for pwm control
34 if [ ! -f /etc/sysconfig/fancontrol ]; then
35 nls "Fancontrol not initialized."
36 nls "Try \`%s init' before start." "$0"
37 exit 6
38 fi
39
40 msg_starting fancontrol
41 # won't start without an output
42 daemon --fork 'fancontrol >/dev/null'
43 RETVAL=$?
44 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fancontrol
45 else
46 msg_already_running fancontrol
47 fi
48 else
49 echo "Start sensors daemon first"
50 exit 1
51 fi
52}
53
54stop() {
55 if [ -f /var/lock/subsys/fancontrol ]; then
56 # Stop daemons.
57 msg_stopping fancontrol
58 # it's crucial to be sure it ended ok, otherwise we get
59 # the fans set and the computer working without any control
60 # and that could cause MASSIVE damage
61 killproc --waitforname fancontrol --waitfortime 30 fancontrol -TERM
62 rm -f /var/lock/subsys/fancontrol
63 else
64 msg_not_running fancontrol
65 fi
66}
67
68restart() {
69 stop
70 start
71}
72
73# See how we were called.
74case "$1" in
75 start)
76 start
77 ;;
78 stop)
79 stop
80 ;;
81 restart)
82 restart
83 ;;
84 init)
85 pwmconfig
86 exit $?
87 ;;
88 status)
89 status fancontrol
90 RETVAL=$?
91 ;;
92 *)
93 msg_usage "$0 {start|stop|restart|status|init}"
94 exit 3
95esac
96
97exit $RETVAL
98
99# This must be last line !
100# vi:syntax=sh
This page took 0.030178 seconds and 4 git commands to generate.