9276c65
#!/bin/bash
9276c65
NAME=ocsinventory-agent
9276c65
9276c65
exec >>/var/log/$NAME/$NAME.log 2>&1 
9276c65
9276c65
[ -f   /etc/sysconfig/$NAME ] || exit 0
9276c65
source /etc/sysconfig/$NAME
9276c65
export PATH
9276c65
9276c65
i=0
9276c65
while [ $i -lt ${#OCSMODE[*]} ]
9276c65
do
9276c65
	if [ ${OCSMODE[$i]:-none} == cron ]; then
9276c65
		OPTS=
9276c65
		if [ ! -z "${OCSPAUSE[$i]}" ]; then
9276c65
			OPTS="--wait ${OCSPAUSE[$i]}"
9276c65
		fi
9276c65
9276c65
		if [ ! -z "${OCSTAG[$i]}" ]; then
9276c65
		        OPTS="$OPTS --tag=${OCSTAG[$i]}"
9276c65
		fi
9276c65
9276c65
		if [ "z${OCSSERVER[$i]}" = 'zlocal' ]; then
9276c65
	        	# Local inventory
9276c65
	        	OPTS="$OPTS --local=/var/lib/$NAME"
9276c65
9276c65
		elif [ ! -z "${OCSSERVER[$i]}" ]; then
9276c65
	        	# Remote inventory
9276c65
		        OPTS="$OPTS --lazy --nolocal --server=${OCSSERVER[$i]}"
baafae0
		        if [ ! -z "${OCSPROXYSERVER[$i]}" ]; then
baafae0
		        	OPTS="$OPTS --proxy=${OCSPROXYSERVER[$i]}"
baafae0
		        fi
9276c65
		fi
9276c65
9276c65
		echo "[$(date '+%c')] Running $NAME $OPTS"
9276c65
		/usr/sbin/$NAME  $OPTS
9276c65
	fi
9276c65
	((i++))
9276c65
done
9276c65
echo "[$(date '+%c')] End of cron job ($PATH)"
9276c65