aboutsummaryrefslogtreecommitdiff
path: root/system/powernowd/rc.powernowd.new
blob: fe6f50f15e9dc60d925aac3e6a9fe316b34de4c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh

# Written by Daniel LEVAI for the Slackware package
# Modified by Robby Workman <rworkman@slackbuilds.org>

# For the options, see the README of the man page
#OPTS='-q'

powernowd_start() {
        local PID=$(pgrep -x powernowd);
        if [ $PID ];then
                echo "powernowd is already running ($PID)"
		exit 1
        else
                /usr/sbin/powernowd $OPTS
        fi
}

powernowd_stop() {
        local PID=$(pgrep -x powernowd);
        if [ -z $PID ];then
                echo "powernowd is not running"
		exit 1
        else
                local i=1
                while pgrep -x powernowd > /dev/null;do
                        if [ $i -gt 3 ];then
                                echo "Couldn't stop powernowd..."
                                exit 1
                        fi
                        pkill -x powernowd
                        i=$(( $i + 1 ));
                        sleep 1;
                done
        fi
}

case "$1" in
start)
	powernowd_start
;;
stop)
	powernowd_stop	
;;
restart)
	powernowd_stop
	sleep 1
	powernowd_start
;;
*)
	echo "$0 <start|stop|restart>"
;;
esac