summaryrefslogtreecommitdiffstats
path: root/admin/zabbix/files/zabbix_server.init
blob: bcbdb41cd7d7e9be5be18aee8e8df80a6353f142 (plain)
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
#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2025 OpenWrt.org

# shellcheck disable=SC2034
START=59

# shellcheck disable=SC2034
USE_PROCD=1

NAME=zabbix_server
PROG=/usr/sbin/${NAME}
CONFIG=/etc/zabbix_server.conf

start_service() {
	if [ ! -f "${CONFIG}" ]; then
		logger "Configuration file not found: '${CONFIG}'"
		return 1
	fi

	# Get enabled config option
	config_load "$NAME"
	config_get_bool enabled general enabled 0

	# shellcheck disable=SC2154
	if [ "$enabled" -eq 0 ]; then
		logger "service not enabled in /etc/config/$NAME"
		return 1
	fi

	mkdir -p /var/run/zabbix-server
	chown zabbix-server:zabbix-server /var/run/zabbix-server

	procd_open_instance
	procd_set_param command ${PROG} -c ${CONFIG} -f
	procd_set_param user zabbix-server
	procd_set_param limits nofile="16384 100000"
	procd_set_param file ${CONFIG}
	procd_set_param respawn
	procd_set_param stdout 1
	procd_set_param stderr 1
	procd_close_instance
}