aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt/zabbix42-server/files/zabbix_server.in
blob: 5454914ff3b3aaace33a268bf1fdb5bb3322b3d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh

# PROVIDE: zabbix_server
# REQUIRE: DAEMON
%%PGSQL%%# REQUIRE: postgresql
%%MYSQL%%# REQUIRE: mysql-server
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf to
# enable zabbix_server:
#
# zabbix_server_enable (bool): Set to NO by default.  Set it to YES to
#         enable zabbix_server.
# zabbix_server_config (string): Set to the standard config file path by
#         default.
# zabbix_server_pidfile (string):    Location of the zabbix_server pid file
#                               Default is /var/run/zabbix/zabbix_server.pid
# zabbix_server_paths (string): Set to standard path by default.  Set a search
#         if you have custom userparams that need binaries elsewhere.
#

. /etc/rc.subr

name="zabbix_server"
rcvar=zabbix_server_enable

load_rc_config $name

: ${zabbix_server_enable:=NO}
: ${zabbix_server_config:=%%ETCDIR%%/${name}.conf}
: ${zabbix_server_pidfile:=/var/run/zabbix/zabbix_server.pid}
: ${zabbix_server_paths:=$PATH}

command="%%PREFIX%%/sbin/${name}"
required_files="${zabbix_server_config}"

start_cmd=zabbix_server_cmd
start_precmd=zabbix_server_precmd 
status_precmd=zabbix_server_precmd
stop_precmd=zabbix_server_precmd

zabbix_server_precmd()
{
	if get_pidfile_from_conf PidFile ${zabbix_server_config}; then
		pidfile="$_pidfile_from_conf"
	else
		pidfile=${zabbix_server_pidfile}
		local rundir=${zabbix_server_pidfile%/*}
		if [ ! -d $rundir ] ; then
			install -d -m 0755 -o zabbix -g zabbix $rundir
		fi
	fi

	# This shouldn't be necessary with pidfile, but empirically it was the
	# only way to reap the parent PID instead of all PIDs from
	# check_process, which may leak SysV IPC objects and prevent restart
	# and/or race condition on restart.
	rc_pid=$(check_pidfile ${pidfile} ${command})
}

zabbix_server_cmd()
{
	PATH=$zabbix_server_paths $command -c $zabbix_server_config
}

run_rc_command "$1"