#!/bin/bash
#
# interact      This shell script starts/stops ebeam-server
#
# Author:       Luidia, Inc.
#
# chkconfig: 235 95 95
# description:  start/stop ebeam server. WARNING: Stopping (and restarting) will also stop Interact
# processname:  ebeam-server
#
# for openSUSE
### BEGIN INIT INFO
# Provides:          ebeam-server
# Required-Start:    $syslog
# Should-Start:
# Required-Stop:     $syslog
# Should-Stop:
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Short-Description: ebeam-server provides an interface to eBeam systems.
# Description:       Start ebeam-server to connect to eBeam systems which
#	provide interactive whiteboard funtionallity.
### END INIT INFO

prog=/usr/sbin/ebeam-server

RETVAL=0

start() {
#	echo -n $"Starting ebeam-server"
	$prog --is_core=1 < /dev/null >& /dev/null &
	sleep 2
#	echo
}

stop() {
# work-around until interact can handle restart of ebeam-server: stop all of the ebeam processes
    killall -9 -Ivr 'ebeam'
#	echo -n $"Stopping ebeam-server"
#	killall ebeam-server
#	echo
}

restart() {
	stop
	start
}

status () {
    procname=`basename $prog`
    killall -q -SIGCONT $procname
    if [ $? = 0 ]
    then
	echo ebeam-server is running
	RETVAL=0
    else
	echo ebeam-server is stopped
	RETVAL=1
    fi
}

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

exit $RETVAL
