#!/bin/bash
#
#   /etc/rc.d/init.d/dbvserverd
#
# Starts the dbvserverd daemon
#
# chkconfig: 345 95 5
# description: Dbvisit GUI daemon initialisation 1.0 03/03/11 HJ \
#              Copyright (c) 2012 by Dbvisit Software Ltd. \
#              All rights reserved.
# processname: dbvserverd 

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

DBVISIT=/usr/local/dbvisit
DBVSERVERD=$DBVISIT/dbvserverd
PIDFILE=$DBVISIT/dbvserver/tmp/dbvserverd.pid
PATH=/usr/bin:/bin:/usr/sbin:/sbin
RETVAL=0
prog="dbvserverd"

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

stop() {
    echo -n $"Stopping $prog: "
    if [ -f "$PIDFILE" ]; then
       killproc $DBVSERVERD
    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
