#!/bin/sh
#
# omniORB:	Starts omniORB
#
# chkconfig:	345 85 15
# description:	This is a daemon which handles CORBA connections for \
#		example for 3dwm.
# processname:	omniNames
# config:	/etc/omniORB.cfg
#

# Sanity checks.
[ -f /etc/omniORB.cfg ] || exit 0

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

# Get sysconfig
[ -f /etc/sysconfig/omniORB ] && . /etc/sysconfig/omniORB

start() {
	if [ ! -f /var/lock/subsys/omniORB ]; then
		msg_starting "omniNames for omniORB"
		if [ -f "/var/log/omniORB/omninames-$(hostname).log" ]; then
			START=
		else
			START=-start
		fi
		daemon "sh -c 'omniNames $START -errlog /var/log/omniORB/omninames-err.log $OMNIORB_OPTS &'"
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/omniORB
	else
		msg_already_running "omniNames for omniORB"
	fi
}

stop() {
	if [ -f /var/lock/subsys/omniORB ]; then
		msg_stopping "omniNames for omniORB"
		killproc omniNames
		rm -f /var/lock/subsys/omniORB >/dev/null 2>&1
	else
		msg_not_running "omniNames for omniORB"
	fi
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  status)
	status omniNames
	exit $?
	;;
  restart|force-reload)
	stop
	start
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
