]>
Commit | Line | Data |
---|---|---|
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 | # |
ca04aac1 | 13 | # TODO: |
ca04aac1 | 14 | # - check this, case this is my first 'advanced' init script |
54f5802c | 15 | # - maybe add some more stop control, like re-running fancontrol and killing |
f8a08288 | 16 | # it once more, if killproc fails |
ca04aac1 | 17 | # |
18 | ||
19 | # Source function library | |
20 | . /etc/rc.d/init.d/functions | |
21 | ||
ca5b4a01 ER |
22 | # Get service config |
23 | [ -f /etc/sysconfig/fancontrol ] && . /etc/sysconfig/fancontrol | |
ca04aac1 | 24 | |
2e25ba16 | 25 | start() { |
54f5802c | 26 | # sensors deamon needs to be started |
f8a08288 | 27 | # or at least proper modules loaded (provided by sensorsd deamon) |
c56172b0 | 28 | if [ ! -f /var/lock/subsys/sensord ]; then |
f8a08288 | 29 | echo "Start sensors daemon first" |
c56172b0 ER |
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 | |
ca04aac1 | 45 | fi |
c56172b0 ER |
46 | |
47 | msg_starting fancontrol | |
48 | # won't start without an output | |
b25344ea | 49 | daemon --fork --redirfds /usr/sbin/fancontrol |
c56172b0 ER |
50 | RETVAL=$? |
51 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fancontrol | |
2e25ba16 ER |
52 | } |
53 | ||
54 | stop() { | |
c56172b0 | 55 | if [ ! -f /var/lock/subsys/fancontrol ]; then |
ca04aac1 | 56 | msg_not_running fancontrol |
c56172b0 | 57 | return |
ca04aac1 | 58 | fi |
c56172b0 ER |
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 | |
2e25ba16 ER |
67 | } |
68 | ||
69 | restart() { | |
70 | stop | |
71 | start | |
72 | } | |
73 | ||
74 | # See how we were called. | |
75 | case "$1" in | |
76 | start) | |
c56172b0 | 77 | start |
2e25ba16 ER |
78 | ;; |
79 | stop) | |
c56172b0 | 80 | stop |
ca04aac1 | 81 | ;; |
82 | restart) | |
c56172b0 | 83 | restart |
ca04aac1 | 84 | ;; |
ca04aac1 | 85 | init) |
c56172b0 ER |
86 | pwmconfig |
87 | exit $? | |
88 | ;; | |
ca04aac1 | 89 | status) |
90 | status fancontrol | |
91 | RETVAL=$? | |
92 | ;; | |
93 | *) | |
c56172b0 | 94 | msg_usage "$0 {start|stop|restart|init|status}" |
ca04aac1 | 95 | exit 3 |
96 | esac | |
97 | ||
98 | exit $RETVAL |