]>
Commit | Line | Data |
---|---|---|
d40c3e06 | 1 | #!/bin/sh |
2 | # Startup script for cpuspeed | |
3 | # | |
4 | # chkconfig: 12345 06 99 | |
5 | # description: Run dynamic CPU speed daemon | |
6 | ||
7 | # Source function library. | |
8 | . /etc/rc.d/init.d/functions | |
9 | ||
10 | [ -f /usr/sbin/cpuspeed ] || exit 0 | |
11 | ||
12 | # Get config. | |
13 | if [ -f /etc/sysconfig/cpuspeed ]; then | |
14 | . /etc/sysconfig/cpuspeed | |
15 | fi | |
16 | ||
17 | start() { | |
18 | if [ ! -f /var/lock/subsys/cpuspeed ]; then | |
19 | # Attempt to load scaling_driver if not loaded but it is configured | |
20 | if [ ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver ]; then | |
21 | [ -n "$DRIVER" ] && /sbin/modprobe "$DRIVER" | |
22 | fi | |
23 | ||
24 | # If not loaded, abort cpuspeed without [FAILED] message | |
25 | [ ! -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver ] && return 0 | |
26 | ||
27 | msg_starting cpuspeed | |
28 | ||
29 | daemon cpuspeed -d $OPTS | |
30 | RETVAL=$? | |
d40c3e06 | 31 | [ $RETVAL = 0 ] && touch /var/lock/subsys/cpuspeed |
32 | else | |
33 | return 0 | |
34 | fi | |
35 | return $RETVAL | |
36 | } | |
37 | ||
38 | stop() { | |
39 | if test "x`pidof cpuspeed`" != x; then | |
40 | msg_stopping cpuspeed | |
41 | killproc cpuspeed -INT | |
42 | sleep 1 | |
d40c3e06 | 43 | fi |
44 | if test "x`pidof cpuspeed`" != x; then | |
45 | killproc cpuspeed | |
46 | fi | |
47 | RETVAL=$? | |
48 | [ $RETVAL = 0 ] && rm -f /var/lock/subsys/cpuspeed | |
49 | return $RETVAL | |
50 | } | |
51 | ||
52 | case "$1" in | |
53 | start) | |
54 | start | |
55 | ;; | |
d40c3e06 | 56 | stop) |
57 | stop | |
58 | ;; | |
d40c3e06 | 59 | status) |
60 | status cpuspeed | |
61 | ;; | |
62 | restart) | |
63 | stop | |
64 | start | |
65 | ;; | |
66 | condrestart) | |
67 | if test "x`pidof cpuspeed`" != x; then | |
68 | stop | |
69 | start | |
70 | fi | |
71 | ;; | |
d40c3e06 | 72 | *) |
73 | echo $"Usage: $0 {start|stop|restart|condrestart|status}" | |
74 | exit 1 | |
75 | ||
76 | esac | |
77 | ||
78 | exit $RETVAL |