#!/bin/bash
#
# wlmproxy:	Starts the wlmproxy daemon
#
# chkconfig: 35 97 03
# description: wlmproxy daemon
#
### BEGIN INIT INFO
# Provides: wlmproxy
# Required-Start: $local_fs $network $syslog
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Short-Description: Starts the wlmproxy daemon
# Description: wlmproxy daemon
### END INIT INFO

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

exec="/usr/sbin/wlmproxy"
prog=$(basename $exec)
config="/etc/wlmproxy/wlmproxy.conf"

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

lockfile=/var/lock/subsys/$prog

check() {
    [ $EUID -eq 0 ] || exit 4
}

start() {
    check
    [ -x $exec ] || exit 5
    [ -f $config ] || exit 6
    echo -n $"Starting $prog: "
    daemon $exec -c $config -d $OPTS
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    check
    echo -n $"Stopping $prog: "
    killproc $exec
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

# See how we were called.
case "$1" in
    start|stop|restart)
	$1
	;;
    status)
	status $prog
	;;
    *)
	echo $"Usage: $0 {start|stop|status|restart}"
	exit 2
esac
exit $?
