updated on Fri Jan 13 08:00:32 UTC 2012
[aur-mirror.git] / spindown / spindown.rc
blob86563e9c2bdfaf541269b7b7ae4519c429bf3561
1 #!/bin/bash
3 CONFPATH="/etc/spindown.conf"
4 VARDIR="/var/run/spindown"
5 FIFOPATH="${VARDIR}/spindownd.fifo"
6 PIDFILE="${VARDIR}/spindownd.pid"
8 . /etc/rc.conf
9 . /etc/rc.d/functions
11 #prints table with status about the disks
12 status() {
13 #print the header of the table
14 printf "%-5s %10s %10s %15s %20s\n" name watched active idle-time spindown-time
16 while read line; do
18 printf "%-5s %10s %10s %15s %20s\n" $line
20 done < ${FIFOPATH}
22 exit 0
25 PID=$(pidof -o %PPID /sbin/spindownd)
26 case "$1" in
27 start)
28 stat_busy "Starting disk spindown daemon"
29 [ ! -d ${VARDIR} ] && mkdir -p ${VARDIR} &> /dev/null
30 [ -z "${PID}" ] && /sbin/spindownd -d -f ${FIFOPATH} -c ${CONFPATH} -p ${PIDFILE}
31 if [ $? -gt 0 ]; then
32 stat_fail
33 else
34 add_daemon spindown
35 stat_done
38 stop)
39 stat_busy "Stopping disk spindown daemon"
40 [ -f "${PIDFILE}" ] && kill $(cat ${PIDFILE}) &>/dev/null
41 if [ $? -gt 0 ]; then
42 stat_fail
43 else
44 rm_daemon spindown
45 stat_done
48 status)
49 [ -z "${PID}" ] && exit 1
50 echo -n
51 status &
52 sleep 0.1
53 kill -PIPE ${PID}
54 wait $!
56 restart)
57 $0 stop
58 sleep 1
59 $0 start
62 echo "usage: $0 {start|stop|restart|status}"
64 esac
65 exit 0