#!/bin/sh
#
# astium  This shell script takes care of starting and stopping astiumd
#               
#
# chkconfig: 2345 92 60
# description: Astium
# processname: astiumd

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

[ -f /usr/local/astium/sbin/astiumd ] || exit 0

RETVAL=0

# See how we were called.
case "$1" in
  start)
        # Start daemons.
        echo -n "Starting Astium daemon: "
        daemon /usr/local/astium/sbin/safe_astiumd
	RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/astium
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down Astium daemon: "
        killproc /usr/local/astium/sbin/safe_astiumd
        killall -9 -q /usr/local/astium/sbin/astiumd
	#kill `cat /var/run/astiumd.pid` 2>/dev/null
	RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/astiumd
        ;;
  status)
	isrunning=`ps aux|grep astiumd|grep -v grep|grep -v status|grep -v vim|grep -v vi`
 
        if [ -n "$isrunning" ]
	then
		echo "Astium daemon is running"
	fi
        if [ -z "$isrunning" ]
	then
		echo "Astium daemon is not running"
	fi
        	
	RETVAL=$?
	;;
  reload)
	RETVAL=$?
	;;
  restart)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
        echo "Usage: astiumd {start|stop|restart|reload|status}"
        exit 1
esac

exit $RETVAL
