#! /bin/sh
#
# @package      hubzero-telequotad
# @file         telequotad.init
# @author       David Benham <dbenham@purdue.edu>
# @copyright    Copyright (c) 2010-2014 HUBzero Foundation, LLC.
# @license      http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
#
# Copyright (c) 2010-2014 HUBzero Foundation, LLC.
#
# This file is part of: The HUBzero(R) Platform for Scientific Collaboration
#
# The HUBzero(R) Platform for Scientific Collaboration (HUBzero) is free
# software: you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# HUBzero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# HUBzero is a registered trademark of HUBzero Foundation, LLC.
#
### BEGIN INIT INFO
# Provides:          telequotad
# Required-Start:    $remote_fs $network $time
# Required-Stop:     $remote_fs $network $time
# Should-Start:      $syslog
# Should-Stop:       $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts telequotad
# Description:       Starts telequotad
### END INIT INFO

# Author: David R. Benham <dbenham@purdue.edu>
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.

# Do NOT "set -e"

DESC="telequotad"
NAME=telequotad
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

LOCKFILE=/var/lock/subsys/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
# . /lib/init/vars.sh

# Source function library.
. /etc/rc.d/init.d/functions

[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME

start() {
    echo -n $"Starting $NAME: "
    daemon --pidfile=${PIDFILE} $DAEMON $DAEMON_ARGS
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $LOCKFILE
}

stop() {
    echo -n $"Stopping $NAME: "
    killproc $DAEMON
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $LOCKFILE
}

restart() {
    stop
    start
}

rh_status() {
    # run checks to determine if the service is running or use generic status
    status $NAME
}


case "$1" in
    start)
        start
	;;
    stop)
		stop
	;;
    restart)
        stop
		start
	;;
    status)
	rh_status
        ;;
    *)
      	echo $"Usage: $0 {start|stop|status|restart}"
        exit 2
esac
exit $?

