#!/bin/sh
#
# omniNames This shell script takes care of loading omniNames
#           for i.e. 3Dwm server
#
# chkconfig: 2345 80 30
#
# description: Lauching omniNames server.
#
# (c) MandrakeSoft, Lenny Cartier <lenny@mandrakesoft.com>
#
# config: /etc/omniORB.cfg

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

RETVAL=0

OMNILOG=/var/log/omniORB/omninames-$HOSTNAME.log
LOCKFILE=/var/lock/subsys/omniNames 

start(){
	echo -n "Starting omniNames daemon: "
	if [ -f "$OMNILOG" ]
	then
	    daemon "omniNames &"
	else
	    daemon "omniNames -start &"
	fi
	RETVAL=$?
	echo
        [ $RETVAL -eq 0 ] && touch "$LOCKFILE"
        return $RETVAL
}

stop(){
	echo -n "Stopping omniNames daemon: "
        killproc omniNames
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
        return $RETVAL
}

restart(){
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		status omniNames
		RETVAL=$?
		;;
	*)
		echo "Usage: ${0##*/} {start|stop|reload|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
