#! /bin/sh
#
# /etc/init.d/gmmapper
#
# gmmapper      Script to initialze the gm driver for the myrinet.
#               Written by a user at ccrl.nj.nec.com 1999
#               This is a simple version.
#
# Version:	@(#)gm - Mon Jun  7 02:33:37 EDT 1999
#
# Do something like 
# cd /etc/rcS.d
# ln -s ../init.d/gmmapper S45gmmapper
# to install the script in the boot process.
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
VER=`uname -r`
HOSTNAME=`hostname`

DAEMON=/usr/src/gm-1.01/binary/sbin/mapper
DAEMONARG=/usr/src/gm-1.01/binary/sbin/active.args
DAEMONFILES="mapper.counters mapper.map $HOSTNAME.hosts"
NAME=mapper
DESC="myrinet mapper"

test -f $DAEMON || exit 0

# set -e

case "$1" in
  start)
	echo "Starting $DESC: "

	echo "killall $DAEMON"
	killall $DAEMON > /dev/null

	echo "$DAEMON $DAEMONARG"
	$DAEMON $DAEMONARG > /dev/null &
	echo "Sleeping 10 seconds to let mapper run"
	sleep 10
		
	;;
  stop)
	echo "Stopping $DESC: "

	echo "killall $DAEMON"
	killall $DAEMON
	
	echo "rm -f $DAEMONFILES"
	rm -f $DAEMONFILES
	
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop}" >&2
	exit 1
	;;
esac

exit 0
