#!/bin/sh
#
# olympusd          Control the Olympus daemon.
#
# chkconfig:   345 55 45
#
# description: Mount Linux Olympus.  And advanced networked 
#	       graphical system administration environment
#	       which allows the user to control hundreds of
#	       systems (of different arch/OS) simultaneously.
#
# Script Author: Sebastien Taylor <sebastien@mountlinux.com>
# 
# I have tried to make this script so that it would work on
# most Linux distributions, I have tested it on SuSE 6.4 
# RedHat 6.2 and Debian Potato, if you find a problem or if
# it doesn't work on your system please send me an email to
# tell me where you are having troubles so that I may fix it.
# Thank you :-)
#
#
# processname: olympusd
#
# config: /etc/olympusd.conf
# config: /etc/olympus.data

SERVER=/usr/sbin/olympusd
LOCKFILE=/var/lock/subsys/olympusd
PIDFILE=/var/run/olympusd.pid

[ -x $SERVER ] || exit 0

PID=0

piderror () {
    echo "olympus does not seem to be running!"
    exit 1;
}

# See how we were called.
case "$1" in
  start)
	echo -n "Starting the Olympus server..."
	$SERVER
        sleep 1s
        PID=`cat $PIDFILE`
        echo
        touch $LOCKFILE
	;;
  stop)
	echo -n "Stopping the Olympus server..."
	PID=`cat $PIDFILE`
        kill $PID
        rm -f $PIDFILE
	rm -f $LOCKFILE
        echo
        ;;
  status)
        [ -f $PIDFILE ] || piderror;
        PID=`cat $PIDFILE`
        cat /proc/$PID/status
	;;
  restart)
  	$0 stop
	$0 start
	;;
  reload)
	killall -HUP olympusd
	;;
  *)
	echo "Usage: olympusd {start|stop|status|restart|reload}"
	exit 1
esac

exit 
