d98816c
#!/bin/bash
d98816c
#
d98816c
# chkconfig: - 88 12
d98816c
# description:	FusionInventory Agent
d98816c
# processname: fusioninventory-agent
d98816c
# config: /etc/sysconfig/fusioninventory-agent.pid
d98816c
# pidfile: /var/run/fusioninventory-agent.pid
d98816c
### BEGIN INIT INFO
d98816c
# Provides: fusioninventory-agent
d98816c
# Required-Start: $local_fs $remote_fs $network $named $syslog $time
d98816c
# Required-Stop: $local_fs $remote_fs $network $named $syslog $time
d98816c
# Default-Start:
d98816c
# Default-Stop: 0 1 6
d98816c
# Short-Description: FusionInventory agent
d98816c
# Description: FusionInventory agent
d98816c
### END INIT INFO
d98816c
d98816c
# source function library
d98816c
. /etc/rc.d/init.d/functions
d98816c
d98816c
RETVAL=0
d98816c
desc="FusionInventory Agent"
d98816c
prog=fusioninventory-agent
d98816c
lockfile=/var/lock/subsys/$prog
d98816c
pidfile=/var/run/$prog.pid
d98816c
logfile=/var/log/$prog/$prog.log
d98816c
d98816c
# pull in sysconfig settings
d98816c
[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
d98816c
d98816c
#
d98816c
# Function that starts the daemon/service
d98816c
#
d98816c
do_start()
d98816c
{
d98816c
	# Read configuration
d98816c
	i=0
d98816c
	OPTS=
d98816c
	SERVERS=
d98816c
	while [ $i -lt ${#OCSMODE[*]} ]
d98816c
	do
d98816c
		if [ ${OCSMODE[$i]:-none} == daemon ]; then
d98816c
			if [ ! -z "${OCSTAG[$i]}" ]; then
d98816c
				OPTS="$OPTS --tag=${OCSTAG[$i]}"
d98816c
			fi
d98816c
			if [ "z${OCSSERVER[$i]}" = 'zlocal' ]; then
d98816c
				# Local inventory
d98816c
				OPTS="$OPTS --local=/var/lib/$prog"
d98816c
			elif [ ! -z "${OCSSERVER[$i]}" ]; then
d98816c
				# Remote inventory
d98816c
				if [ -z "$SERVERS" ]; then
d98816c
					SERVERS=${OCSSERVER[$i]}
d98816c
				else
d98816c
					SERVERS="$SERVERS,${OCSSERVER[$i]}"
d98816c
				fi
d98816c
			fi
d98816c
		fi
d98816c
		((i++))
d98816c
	done
d98816c
	if [ -n "$SERVERS" ]; then
d98816c
		OPTS="$OPTS --server=$SERVERS"
d98816c
	fi
d98816c
	if [ -n "$OPTS" ]; then
d98816c
		echo -n $"Starting $prog: "
d98816c
		daemon $prog --logfile-maxsize=999 --logfile=$logfile $FUSINVOPT --daemon $OPTS 2>/dev/null
d98816c
		RETVAL=$?
d98816c
		echo
d98816c
                [ $RETVAL -eq 0 ] && touch $lockfile
d98816c
	else
d98816c
		RETVAL=0
d98816c
	fi
d98816c
}
d98816c
d98816c
#
d98816c
# Function that stops the daemon/service
d98816c
#
d98816c
do_stop()
d98816c
{
d98816c
	echo -n $"Stopping $prog: "
d98816c
	killproc $prog
d98816c
	RETVAL=$?
d98816c
	echo
d98816c
	if [ $RETVAL -eq 0 ] ; then
d98816c
	    rm -f $lockfile $pidfile
d98816c
	fi
d98816c
}
d98816c
d98816c
case "$1" in
d98816c
  start)
d98816c
	do_start
d98816c
	;;
d98816c
  stop)
d98816c
	do_stop
d98816c
	;;
d98816c
  status)
d98816c
	status $prog
d98816c
	;;
d98816c
  restart|reload|force-reload)
d98816c
	do_stop
d98816c
	do_start
d98816c
	;;
d98816c
  condrestart)
d98816c
	[ -f $lockfile ] && do_stop && do_start || :
d98816c
	;;
d98816c
  *)
d98816c
	echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
d98816c
	exit 1
d98816c
	;;
d98816c
esac
d98816c
exit $RETVAL
d98816c