#!/bin/sh
#
# pvmd		pvmd (Parallel Virtual Machine daemon)
#
# chkconfig:	345 65 45
#
# description:	PVM is a daemon which permits you to use libpvm3. This is \
#		a library which supports parallel computing.


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

# Get network config
. /etc/sysconfig/network

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down "Parallel Virtual Machine"
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/pvmd ]; then
		msg_starting "Parallel Virtual Machine"
		daemon pvmd3 &
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pvmd
	else
		msg_already_running "Parallel Virtual Machine"
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/pvmd ]; then
		msg_stopping "Parallel Virtual Machine"
		killproc pvmd3
		rm -f /var/run/pvmd.pid /var/lock/subsys/pvmd >/dev/null 2>&1
	else
		msg_not_running "Parallel Virtual Machine"
	fi
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status pvmd3
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
