#!/bin/sh
#
# IBM(c) 2014 Apache 2.0
# chkconfig: 345 85 60
# description: Confluent hardware manager
#
### BEGIN INIT INFO
# Provides: confluent
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
### END INIT INFO

confluent=/usr/bin/confluent
prog=confluent
pidfile=/var/run/confluent/pid
lockfile=/var/lock/subsys/confluent

. /etc/rc.d/init.d/functions

start() {
	echo -n $"Starting $prog: "

    daemon --pidfile=${pidfile} $confluent
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch ${pidfile}
    return $RETVAL
}


stop() {
	echo -n $"Stopping $prog: "
    killproc -p ${pidfile} ${prog}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
    return $RETVAL
}

restart() {
    stop
    start
}

rh_status() {
	status -p ${pidfile} ${prog}
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
	rh_status_q && exit 0
	$1
	;;
    stop)
	rh_status_q || exit 1
	$1
	;;
    restart)
	$1
	;;
    status)
	rh_status
	;;
    usage)
	$1
	;;
    *)
	usage
	exit 2
esac
exit $?
