#!/bin/bash
#
#   /etc/rc.d/init.d/dbvnetd
#
# Starts the dbvnetd daemon
#
# chkconfig: 345 95 5
# description: Dbvisit network infrastructure daemon. \
#              Copyright (c) 2012 by Dbvisit Software Ltd. \
#              All rights reserved.
# processname: dbvnetd 

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

DBVISIT=/usr/local/dbvisit
DBVNETD=$DBVISIT/dbvnet/dbvnetd
PIDFILE=$DBVISIT/dbvnet/tmp/dbvnetd.pid
PATH=/usr/bin:/bin:/usr/sbin:/sbin
RETVAL=0
prog="dbvnetd"

start() {
    # Check if already running
    echo -n $"Starting $prog: "
    su -l oracle -c "$DBVNETD"
    RETVAL=$?
    echo
    return $RETVAL
    }

stop() {
    echo -n $"Stopping $prog: "
    if [ -f "$PIDFILE" ]; then
       killproc $DBVNETD
    fi
    RETVAL=$?
    echo
    return $RETVAL
    }

restart() {
    stop
    start
    }

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

exit $?
exit $RETVAL
