updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / cdpolld / cdpolld.rcd
blobd6515b430f8a3d11c63fa614d52a05fdbb39c0d9
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 [ -f /etc/conf.d/cdpolld ] && . /etc/conf.d/cdpolld
8 DEVLIST=${DEVLIST:-/dev/sr0}
9 TIMEOUT=${TIMEOUT:-2}
11 poll_daemon(){
12 PIDFILE="/var/run/`basename $0`.pid"
14 touch $PIDFILE &>/dev/null
15 [ $? -gt 0 ] && return 1
16 SELFPID=`pidof -x $0`
18 trap "rm -f $PIDFILE;return 0" 0 &>/dev/null
19 trap "rm -f $PIDFILE;return 0" SIGINT &>/dev/null
20 trap "rm -f $PIDFILE;return 0" SIGQUIT &>/dev/null
21 trap "rm -f $PIDFILE;return 0" SIGKILL &>/dev/null
22 trap "rm -f $PIDFILE;return 0" SIGTERM &>/dev/null
24 pidof -o $SELFPID -x $0 >$PIDFILE
25 [ $? -gt 0 ] && return 1
26 while [ -n "1" ]; do
27 for DEV in "${DEVLIST[@]}"; do
28 touch $DEV |logger
29 done
30 sleep $TIMEOUT
31 done
32 ) &
33 return 0
36 start(){
37 stat_busy "Starting cdpolld"
38 PID=`pidof -x -o %PPID cdpolld`
39 [ -z $PID ] && poll_daemon
40 if [ $? -gt 0 ]; then
41 stat_fail
42 else
43 add_daemon cdpolld
44 stat_done
48 stop(){
49 stat_busy "Stopping cdpolld"
50 PID=`pidof -x -o %PPID cdpolld`
51 [ ! -z $PID ] && kill $PID &>/dev/null
52 if [ $? -gt 0 ]; then
53 stat_fail
54 else
55 rm_daemon cdpolld
56 stat_done
60 case "$1" in
61 start) start;;
62 stop) stop;;
63 restart) stop; sleep 2; start;;
64 *) echo "usage: $0 {start|stop|restart}";;
65 esac
66 exit 0