#!/bin/sh
#
# srrmodule       This shell script takes care of starting and stopping
#                 the loadable module for QNX Send/Receive/Reply.
#
# description: Srr is a loadable module for QNX Send/Receive/Reply \
# message passing.

# configuration
module="srripc"
device="srripc"
group="root"
mode="666"
major=10
minor=171

modpath=${SRRPATH:-/lib/modules/`uname -r`/misc}/

[ -f $modpath$module.o ] || exit 1

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

# See how we were called.
case "$1" in
  load | start | testload)
        # Start daemons.
        echo -n "Loading srr: "
		# Remove stale nodes and replace them
		rm -f /dev/${device}
		mknod /dev/${device} c $major $minor
		chgrp $group /dev/${device}
		chmod $mode  /dev/${device}

		# load module
		if test "$1" = "testload"
		then
			/sbin/insmod $modpath$module.o || exit 1
		else
			/sbin/modprobe $module || exit 1
		fi

		success srr "module loaded"
		echo
        ;;
  unload | stop)
        # Stop daemons.
        echo -n "Unloading srr: "

		# invoke rmmod
		/sbin/rmmod $module || exit 1

		# Remove stale nodes
		rm -f /dev/${device}

		success srr "module unloaded"
		echo
        ;;
  status)
	echo "not yet implemented"
	exit $?
	;;
  restart)
	echo "not yet implemented"
	exit $?
	;;
  reload)
	echo "not yet implemented"
	exit $?
	;; 
  probe)
	echo "not yet implemented"
	exit 0
	;;
  
  *)
        echo "Usage: named {start|stop|status|restart|reload|probe}"
        exit 1
esac

exit 0

