From 49036b224ddd567d1d34f581f81ba71eaf7691f1 Mon Sep 17 00:00:00 2001 From: Marcin Krol Date: Thu, 20 Jul 2023 13:43:38 +0200 Subject: [PATCH] - init script for Zabbix Agent 2 --- zabbix_agent2.init | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 zabbix_agent2.init diff --git a/zabbix_agent2.init b/zabbix_agent2.init new file mode 100644 index 0000000..f4885d1 --- /dev/null +++ b/zabbix_agent2.init @@ -0,0 +1,96 @@ +#!/bin/sh +# +# Starts the zabbix_agent2 daemon +# +# chkconfig: 345 95 5 +# +# description: zabbix_agent2 long service description +# +# processname: zabbix_agent2 + +# Source function library +. /etc/rc.d/init.d/functions + +# Get network config +. /etc/sysconfig/network + +# Check that networking is up. +if is_yes "${NETWORKING}"; then + if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then + msg_network_down "Zabbix Agent 2" + exit 1 + fi +else + exit 0 +fi + +# Get service config - may override defaults +[ -f /etc/sysconfig/zabbix_agent2 ] && . /etc/sysconfig/zabbix_agent2 + +pidfile="/var/run/zabbix/zabbix_agent2.pid" + +start() { + # Check if the service is already running? + if [ -f /var/lock/subsys/zabbix_agent2 ]; then + msg_already_running "Zabbix Agent 2" + return + fi + + msg_starting "Zabbix Agent 2" + daemon /usr/sbin/zabbix_agent2 + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agent2 +} + +stop() { + if [ ! -f /var/lock/subsys/zabbix_agent2 ]; then + msg_not_running "Zabbix Agent 2" + return + fi + + # Stop daemons. + msg_stopping "Zabbix Agent 2" + killproc --pidfile $pidfile zabbix_agent2 -TERM + rm -f /var/lock/subsys/zabbix_agent2 +} + +condrestart() { + if [ ! -f /var/lock/subsys/zabbix_agent2 ]; then + msg_not_running "Zabbix Agent 2" + RETVAL=$1 + return + fi + + stop + start +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + try-restart) + condrestart 0 + ;; + force-reload) + condrestart 7 + ;; + status) + status --pidfile $pidfile zabbix_agent2 + RETVAL=$? + ;; + *) + msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" + exit 3 +esac + +exit $RETVAL -- 2.46.0