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