#!/bin/sh
# 
# GM Myrinet Device Driver for Parastation
#
# Script to load/unload the module and configure the interface
#
# Author: Jens Hauke <hauke@par-tec.com>, Norbert Eicker <eicker@par-tec.com>
#
# $Id: ps_gm 3882 2006-01-02 10:24:47Z eicker $
#

#checks
test ${PS_ID?"missing env PS_ID"}

#defaults
PS_INSTALLDIR=${PS_INSTALLDIR-"/opt/parastation"}
PS_IPENABLED=${PS_IPENABLED-"0"}
PS_IPPREFIX=${PS_IPPREFIX-"192.168.48"}
PS_IPPREFIXLEN=${PS_IPPREFIXLEN-"20"}

PS_GMCOUNTERS=${PS_INSTALLDIR}/scripts/ps_gmcounters

GM_INSTALLDIR=${GM_INSTALLDIR-"/opt/gm"}
case "$1" in
    start)
	# /etc/init.d/gm start
	out=`/etc/init.d/gm start | grep "Could not install GM module"`
	if [ -n "$out" ]; then
	    echo $out
	    exit 1
	fi

	# if [ "$PS_IPENABLED" = "1" ]; then
	#     /sbin/ifconfig myri0 up
	# fi
	
	;;

    stop)
	# if [ "$PS_IPENABLED" = "1" ]; then
	#     /sbin/ifconfig myri0 down
	# fi
	/etc/init.d/gm stop
	;;

    statusheader)
	if [ -x ${PS_GMCOUNTERS} ]; then
		${PS_GMCOUNTERS} -header
	else
		echo "  **** Cannot get header ****"
	fi
	;;

    status)
	if [ -x ${PS_GMCOUNTERS} ]; then
		${PS_GMCOUNTERS}
	else
		echo "  No counters available"
	fi
	;;

    *)
	echo "Usage: $0 {start|stop|statusheader|status}"
	exit 1
	;;
esac


exit 0
