#!/bin/bash
#
# Start and Stop aims2sync
#
# /etc/init.d/aims2sync
#
# chkconfig: 35 99 99
# description: Starts and stops the aims2 database\
#              to server sycronisation, maintaining the correct\
#              state in /tftpboot/
# probe: true
# config: /etc/sysconfig/aims2
# pidfile: /var/run/aims2sync

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

# Source aims2 configuration.
[ -f /etc/sysconfig/aims2 ] && . /etc/sysconfig/aims2


prog="aims2sync"

RETVAL=0

start() {
        [ -x /usr/sbin/$prog ] || exit 5
	echo -n $"Starting $prog: "
	daemon $prog $AIMS2SYNCARGS
	RETVAL=$?
	echo
        [ $RETVAL -ne 0 ] && exit $RETVAL
        touch /var/lock/subsys/aims2/aims2sync
}

stop() {
        [ -x /usr/sbin/$prog ] || exit 5
	echo -n "Stopping $prog: "
	killproc $prog
	RETVAL=$?
	echo
        rm -f /var/lock/subsys/aims2/aims2sync
	return $RETVAL
}


case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  reload|restart)
	stop
	start
	RETVAL=$?
	;;
  status)
	status $prog
	RETVAL=$?
        [ -f /var/lock/subsys/aims2/aims2.DBDOWN ] && warning "Database connection is DOWN"
	;;
  *)
	echo "Usage: $0 {start|stop|restart|reload|status}"
	RETVAL=3
esac

exit $RETVAL
