--- rpms/zabbix/contribs9/zabbix-proxy.init 2020/05/14 03:29:52 1.1 +++ rpms/zabbix/contribs9/zabbix-proxy.init 2020/05/14 03:38:49 1.2 @@ -1,75 +1,88 @@ -#! /bin/sh +#!/bin/sh # # chkconfig: - 85 15 -# description: zabbix proxy daemon +# description: Zabbix proxy daemon +# config: /etc/zabbix/zabbix_proxy.conf # ### BEGIN INIT INFO -# Provides: zabbix +# Provides: zabbix-proxy # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 -# Short-Description: start and stop zabbix proxy -# Description: Zabbix Proxy +# Short-Description: Start and stop Zabbix proxy +# Description: Zabbix proxy ### END INIT INFO -# zabbix details -if [ -x /usr/sbin/zabbix_proxy_mysql ]; then - ZABBIX_PROXY=zabbix_proxy_mysql -elif [ -x /usr/sbin/zabbix_proxy_pgsql ]; then - ZABBIX_PROXY=zabbix_proxy_pgsql -elif [ -x /usr/sbin/zabbix_proxy_sqlite3 ]; then - ZABBIX_PROXY=zabbix_proxy_sqlite3 +# Source function library. +. /etc/rc.d/init.d/functions + +if [ -x /usr/sbin/zabbix_proxy ]; then + exec=/usr/sbin/zabbix_proxy else exit 5 fi -CONF=/etc/zabbix/zabbix_proxy.conf -PIDFILE=/var/run/zabbix.pid - -# Source function library. -. /etc/rc.d/init.d/functions - -# Source networking configuration. -. /etc/sysconfig/network +prog=${exec##*/} +conf=/etc/zabbix/zabbix_proxy.conf +pidfile=$(grep -e "^PidFile=.*$" $conf | cut -d= -f2 | tr -d '\r') +timeout=10 -# Check that networking is up. -[ ${NETWORKING} = "no" ] && exit 0 +if [ -f /etc/sysconfig/zabbix-proxy ]; then + . /etc/sysconfig/zabbix-proxy +fi -[ -e $CONF ] || exit 6 +lockfile=/var/lock/subsys/zabbix-proxy -RETVAL=0 +start() +{ + echo -n $"Starting Zabbix proxy: " + daemon $exec -c $conf + rv=$? + echo + [ $rv -eq 0 ] && touch $lockfile + return $rv +} + +stop() +{ + echo -n $"Shutting down Zabbix proxy: " + killproc -p $pidfile -d $timeout $prog + rv=$? + echo + [ $rv -eq 0 ] && rm -f $lockfile + return $rv +} + +restart() +{ + stop + start +} case "$1" in - start) - echo -n "Starting Zabbix proxy: " - daemon $ZABBIX_PROXY -c $CONF - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix-proxy - ;; - stop) - echo -n "Shutting down Zabbix proxy: " - killproc $ZABBIX_PROXY - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix-proxy + start|stop|restart) + $1 ;; - restart|reload) - $0 stop - $0 start - RETVAL=$? + force-reload) + restart ;; status) - status $ZABBIX_PROXY - RETVAL=$? + status -p $pidfile $prog + ;; + try-restart|condrestart) + if status $prog >/dev/null ; then + restart + fi + ;; + reload) + action $"Service ${0##*/} does not support the reload action: " /bin/false + exit 3 ;; *) - echo "Usage: $0 {start|stop|restart|reload|status}" - exit 1 + echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" + exit 2 ;; esac -exit $RETVAL -