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

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

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

RETVAL=0

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

exit $RETVAL
