File fusioninventory-agent.init of Package fusioninventory-agent
#!/bin/bash
#
# chkconfig: 345 88 12
# description: FusionInventory Agent
# processname: fusioninventory-agent
# config: /etc/sysconfig/fusioninventory-agent.pid
# pidfile: /var/run/fusioninventory-agent.pid
#
### BEGIN INIT INFO
# Provides: fusioninventory-agent
# Required-Start: $remote_fs $named $syslog
# Required-Stop: $remote_fs $named $syslog
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: FusionInventory Agent
# Description: FusionInventory Agent
### END INIT INFO
if [ -r /etc/rc.status ]
then
source /etc/rc.status
START="/sbin/startproc"
STATUS="/sbin/checkproc"
SUCCESS="echo \$rc_done"
FAILURE="echo \$rc_failed"
else
source /etc/rc.d/init.d/functions
START="daemon"
STATUS="status"
SUCCESS="success; echo"
FAILURE="failure; echo"
fi
RETVAL=0
desc="FusionInventory Agent"
prog=fusioninventory-agent
pidfile=/var/run/$prog.pid
logfile=/var/log/$prog/$prog.log
# pull in sysconfig settings
[ -r /etc/sysconfig/$prog ] && source /etc/sysconfig/$prog
#
# Function that starts the daemon/service
#
do_start()
{
# Read configuration
i=0
OPTS=
while [ $i -lt ${#OCSMODE[*]} ]
do
if [ ${OCSMODE[$i]:-none} == daemon ]; then
if [ ! -z "${OCSTAG[$i]}" ]; then
OPTS="$OPTS --tag=${OCSTAG[$i]}"
fi
if [ "z${OCSSERVER[$i]}" = 'zlocal' ]; then
# Local inventory
OPTS="$OPTS --local=/var/lib/$prog"
elif [ ! -z "${OCSSERVER[$i]}" ]; then
# Remote inventory
OPTS="$OPTS --server=${OCSSERVER[$i]}"
fi
fi
((i++))
done
if [ -n "$OPTS" ]; then
echo -n "Starting $prog: "
$START $prog $FUSINVOPT --logfile=$logfile --daemon $OPTS
RETVAL=$?
else
RETVAL=1
fi
[ $RETVAL -eq 0 ] && eval "$SUCCESS" || eval "$FAILURE"
}
#
# Function that stops the daemon/service
#
do_stop()
{
echo -n "Stopping $prog: "
killproc $prog
RETVAL=$?
[ $RETVAL -eq 0 ] && eval "$SUCCESS" || eval "$FAILURE"
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
status)
$STATUS $prog
RETVAL=$?
[ $RETVAL -eq 0 ] && eval "$SUCCESS" || eval "$FAILURE"
;;
restart|reload|force-reload)
do_stop
do_start
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
exit 1
;;
esac
exit $RETVAL