#!/bin/sh
#
# chkconfig: 345 99 01
# description: Startup script for ingraph daemon
# processname: ingraphd

### BEGIN INIT INFO
# Provides: ingraph
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Should-Start: mysql postgresql
# Should-Stop: mysql postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Short description.
# Description: Description.
### END INIT INFO

INGRAPH_CHDIR="/etc/ingraph"
INGRAPH_PIDFILE="/var/run/ingraph/ingraphd.pid"
INGRAPH_USER="ingraph"
INGRAPH_LOGFILE="-" # stdout/stderr

[ -r /etc/default/ingraph ] && . /etc/default/ingraph
[ -r /etc/sysconfig/ingraph ] && . /etc/sysconfig/ingraph

RETVAL=0

do_action() {
    python -m ingraph/bin/ingraphd -d "$INGRAPH_CHDIR" -p "$INGRAPH_PIDFILE" \
    -u "$INGRAPH_USER" -o "$INGRAPH_LOGFILE" "$1"
    RETVAL="$?"
}

case "$1" in
    start|stop|restart|status)
        do_action $1
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|status}"
        RETVAL=1
esac

exit $RETVAL
