]> git.pld-linux.org Git - packages/zabbix.git/blame - zabbix_agent2.init
up to 6.0.18
[packages/zabbix.git] / zabbix_agent2.init
CommitLineData
1afc63f3
ER
1#!/bin/sh
2#
3# Starts the zabbix_agent2 daemon
4#
5# chkconfig: 345 95 5
6#
7# description: zabbix_agent2 long service description
8#
9# processname: zabbix_agent2
10# processname: zabbix_agent2
11# Source function library
12. /etc/rc.d/init.d/functions
13
14# Get network config
15. /etc/sysconfig/network
16
17# Check that networking is up.
18if is_yes "${NETWORKING}"; then
19 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
20 msg_network_down "Zabbix Agent2"
21 exit 1
22 fi
23else
24 exit 0
25fi
26
27ZABBIX_USER=zabbix
28
29# Get service config - may override defaults
30[ -f /etc/sysconfig/zabbix_agent2 ] && . /etc/sysconfig/zabbix_agent2
31
c53084ae
AS
32# Try to get configured PidFile or set default
33get_pid() {
34 local config="$1"
35 local pidfile
36 test -f "$config" && pidfile=$(awk -F= '/^ *PidFile/ {print $2}' "$config")
37 # Fallback to zabbix_agent2 default pidfile
38 test -n "$pidfile" || pidfile=/tmp/zabbix_agent2.pid
39 echo "$pidfile"
40}
41
42pidfile=$(get_pid /etc/zabbix/zabbix_agent2.conf)
1afc63f3
ER
43
44start() {
45 # Check if the service is already running?
46 if [ -f /var/lock/subsys/zabbix_agent2 ]; then
47 msg_already_running "Zabbix Agent2"
48 return
49 fi
50
51 msg_starting "Zabbix Agent2"
52 daemon --fork --user $ZABBIX_USER /usr/sbin/zabbix_agent2
53 RETVAL=$?
54 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agent2
55}
56
57stop() {
58 if [ ! -f /var/lock/subsys/zabbix_agent2 ]; then
59 msg_not_running "Zabbix Agent2"
60 return
61 fi
62
63 # Stop daemons.
64 msg_stopping "Zabbix Agent2"
65 killproc --pidfile $pidfile zabbix_agent2 -TERM
66 rm -f /var/lock/subsys/zabbix_agent2
67}
68
69condrestart() {
70 if [ ! -f /var/lock/subsys/zabbix_agent2 ]; then
71 msg_not_running "Zabbix Agent2"
72 RETVAL=$1
73 return
74 fi
75
76 stop
77 start
78}
79
80RETVAL=0
81# See how we were called.
82case "$1" in
83 start)
84 start
85 ;;
86 stop)
87 stop
88 ;;
89 restart)
90 stop
91 start
92 ;;
93 try-restart)
94 condrestart 0
95 ;;
96 force-reload)
97 condrestart 7
98 ;;
99 status)
100 status --pidfile $pidfile zabbix_agent2
101 RETVAL=$?
102 ;;
103 *)
104 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
105 exit 3
106esac
107
108exit $RETVAL
This page took 0.300812 seconds and 4 git commands to generate.