#!/bin/sh
#
# vacm  		This shell script takes care of starting Nexxus (The daemon
#        		component of VACM).
#
# chkconfig: 345 55 45
# description: VA Cluster Manager initialization script.
# probe: true

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

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up
[ "${NETWORKING}" = "no" ] && exit 0

[ -f /usr/bin/nexxus ] || exit 0

[ -f /usr/lib/vacm/vacm_configuration ] || exit 0

CONFIG=/etc/sysconfig/vacm

# See how we were called.
case "$1" in
	start)
    # Load the rocket module if necessary
    test -r "$CONFIG" && . "$CONFIG"
    if [ "$ROCKET" = "true" -o "$ROCKET" = "yes" ]; then
      /sbin/lsmod | grep -q ^rocket
      RETVAL=$?
      if [ $RETVAL -ne 0 ]; then
		    echo -n "Loading rocketport module: "
        /sbin/modprobe rocket >/dev/null 2>&1
        RETVAL=$?
        if [ $RETVAL -ne 0 ]; then
          echo_failure
        else
          echo_success
        fi
        echo
      fi
    fi

		# Start daemon.
		echo -n "Starting nexxus: "
    PIDS=`pidof nexxus`
    if [ "$PIDS" != "" ]; then
      echo_failure
      echo
      echo "Nexxus already running with pids ($PIDS)."
      exit 0
     fi

    if [ -S /tmp/vacm ]; then
      echo_failure
      echo
      echo "Stale /tmp/vacm exists.  Clean up and restart. (rm -f /tmp/vacm)"
      exit 0
    fi 

		/usr/bin/nexxus >/dev/null 2>&1 &
    sleep 1
    PIDS=`pidof nexxus`
    if [ "$PIDS" != "" ]; then
      echo_success
		  touch /var/lock/subsys/nexxus
    else
      echo_failure
    fi
    echo 
		;;
	stop)
		# Stop daemon.
		echo -n "Stopping nexxus: "
		killproc nexxus 
		rm -f /var/lock/subsys/nexxus
		echo
		;;
	status)
		status nexxus
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		echo "Usage: vacm {start|stop|status|restart}"
		exit 1
esac

exit 0

# $Id: vacm.init,v 1.4 2000/08/22 14:24:56 zacs Exp $
