updated on Wed Jan 11 12:00:27 UTC 2012
[aur-mirror.git] / monitorix / rc.monitorix
blobd19f34c9e5dc8b9d9e3a73cd1e34e85f33925ca5
1 #!/bin/bash
2 . /etc/rc.conf
3 . /etc/rc.d/functions
5 pidfile="/run/monitorix.pid"
6 if [[ -r $pidfile ]]; then
7 read -r PID < "$pidfile"
8 if [[ ! -d /proc/$PID ]]; then
9 unset PID && rm -f "$pidfile" # stale pidfile
13 args=(-c /etc/monitorix.conf -p "$pidfile")
15 case "$1" in
16 start)
17 stat_busy "Starting Monitorix"
18 if [[ -z $PID ]] && /usr/bin/monitorix "${args[@]}"; then
19 add_daemon monitorix
20 stat_done
21 else
22 stat_fail
23 exit 1
27 stop)
28 stat_busy "Stopping Monitorix"
29 if [[ $PID ]] && kill $PID &> /dev/null; then
30 rm_daemon monitorix
31 [[ -f $pidfile ]] && rm -f $pidfile
32 stat_done
33 else
34 stat_fail
35 exit 1
39 restart)
40 $0 stop
41 sleep 1
42 $0 start
46 echo "usage: $0 {start|stop|restart}"
47 esac