updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / sleepd-git / sleepd.rc
blob6f7d2791d73ad6eef87121f1cb0cebe8fe0a13e0
1 #!/bin/bash
3 daemon_bin=/usr/sbin/sleepd
4 daemon_name=sleepd
5 daemon_desc="sleep daemon"
7 test -f $daemon_bin || exit 1
9 . /etc/rc.conf
10 . /etc/rc.d/functions
12 PARAMS=()
13 [ -r /etc/conf.d/$daemon_name ] && . /etc/conf.d/$daemon_name
15 #set -e # terminate script on any error?
17 function get_pid {
18 pidof -o %PPID $daemon_bin
21 case "$1" in
22 start)
23 # Ensure apm module is loaded.
24 # test -e /dev/apm_bios && touch /dev/apm_bios
25 # do hal (and acpi) need to be started?
26 ck_daemon hal && /etc/rc.d/hal start
28 stat_busy "Starting $daemon_desc"
29 PID=`get_pid`
30 if [ -z "$PID" ]; then
31 [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
32 $daemon_bin "${PARAMS[@]}"
33 if [ $? -eq 0 ]; then
34 echo `get_pid` > /var/run/$daemon_name.pid
35 add_daemon $daemon_name
36 stat_done
37 exit 0
38 fi
40 stat_fail
42 stop)
43 stat_busy "Stopping $daemon_desc"
44 PID=`get_pid`
45 [ ! -z "$PID" ] && kill $PID &> /dev/null
46 if [ $? -eq 0 ]; then
47 rm -f /var/run/$daemon_name.pid &> /dev/null
48 rm_daemon $daemon_name
49 stat_done
50 exit 0
52 stat_fail
54 restart|force-reload)
55 $0 stop
56 sleep 1
57 $0 start
58 exit $?
61 echo "Usage: $0 {start|stop|restart}" >&2
62 esac
63 exit 1