Blame SOURCES/zabbix-agent2.init

1c3a77
#!/bin/sh
1c3a77
#
1c3a77
# chkconfig: - 86 14
1c3a77
# description: Zabbix agent 2 daemon
1c3a77
# processname: zabbix_agent2
1c3a77
# config: /etc/zabbix/zabbix_agent2.conf
1c3a77
#
1c3a77
1c3a77
### BEGIN INIT INFO
1c3a77
# Provides: zabbix-agent2
1c3a77
# Required-Start: $local_fs $network
1c3a77
# Required-Stop: $local_fs $network
1c3a77
# Should-Start: zabbix zabbix-proxy
1c3a77
# Should-Stop: zabbix zabbix-proxy
1c3a77
# Default-Start:
1c3a77
# Default-Stop: 0 1 2 3 4 5 6
1c3a77
# Short-Description: Start and stop Zabbix agent 2
1c3a77
# Description: Zabbix agent 2
1c3a77
### END INIT INFO
1c3a77
1c3a77
# Source function library.
1c3a77
. /etc/rc.d/init.d/functions
1c3a77
1c3a77
if [ -x /usr/sbin/zabbix_agent2 ]; then
1c3a77
    exec=/usr/sbin/zabbix_agent2
1c3a77
else
1c3a77
    exit 5
1c3a77
fi
1c3a77
1c3a77
prog=${exec##*/}
1c3a77
conf=/etc/zabbix/zabbix_agent2.conf
1c3a77
pidfile=$(grep -e "^PidFile=.*$" $conf | cut -d= -f2 | tr -d '\r')
1c3a77
timeout=10
1c3a77
1c3a77
if [ -f /etc/sysconfig/zabbix-agent2 ]; then
1c3a77
    . /etc/sysconfig/zabbix-agent2
1c3a77
fi
1c3a77
1c3a77
if [ -n "$ZABBIX_AGENT_USER" ]; then
1c3a77
    user_conf="--user=$ZABBIX_AGENT_USER"
1c3a77
else
1c3a77
    user_conf=''
1c3a77
fi
1c3a77
1c3a77
lockfile=/var/lock/subsys/zabbix-agent2
1c3a77
1c3a77
start()
1c3a77
{
1c3a77
    echo -n $"Starting Zabbix agent 2: "
1c3a77
    daemon $user_conf $exec -c $conf &
1c3a77
    rv=$?
1c3a77
    echo
1c3a77
    [ $rv -eq 0 ] && touch $lockfile
1c3a77
    return $rv
1c3a77
}
1c3a77
1c3a77
stop()
1c3a77
{
1c3a77
    echo -n $"Shutting down Zabbix agent 2: "
1c3a77
    killproc -p $pidfile -d $timeout $prog
1c3a77
    rv=$?
1c3a77
    echo
1c3a77
    [ $rv -eq 0 ] && rm -f $lockfile
1c3a77
    return $rv
1c3a77
}
1c3a77
1c3a77
restart()
1c3a77
{
1c3a77
    stop
1c3a77
    start
1c3a77
}
1c3a77
1c3a77
case "$1" in
1c3a77
    start|stop|restart)
1c3a77
        $1
1c3a77
        ;;
1c3a77
    force-reload)
1c3a77
        restart
1c3a77
        ;;
1c3a77
    status)
1c3a77
        status -p $pidfile $prog 
1c3a77
        ;;
1c3a77
    try-restart|condrestart)
1c3a77
        if status $prog >/dev/null ; then
1c3a77
            restart
1c3a77
        fi
1c3a77
        ;;
1c3a77
    reload)
1c3a77
        action $"Service ${0##*/} does not support the reload action: " /bin/false
1c3a77
        exit 3
1c3a77
        ;;
1c3a77
    *)
1c3a77
	echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
1c3a77
	exit 2
1c3a77
	;;
1c3a77
esac
1c3a77