Files
Daniel F. Dickinson ec54972924 zabbix: tweak server initscript and bring agentd to parity
* Genericize zabbix_server initscript.
* Add shellcheck overrides where needed.
* Add a 'never_root' config option (default true) that determines
  whether server starts as an unprivileged user or starts as root and
  drops to an unprivileged user (unless config is changed so it always
  runs as root).
* Bring zabbix_agentd initscript to parity with zabbix_server for the
  initscript and configuration.
* Tweak Makefile to reduce repetition

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
2026-07-31 12:50:45 +03:00

52 lines
1.1 KiB
Bash
Executable File

#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2025 OpenWrt.org
# shellcheck shell=busybox
# shellcheck disable=SC2034
START=59
# shellcheck disable=SC2034
USE_PROCD=1
NAME=zabbix_server
PROG=/usr/sbin/${NAME}
CONFIG=/etc/${NAME}.conf
UCI_CONFIG=/etc/config/${NAME}
USER=zabbix-server
start_service() {
local enabled never_root
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
config_get_bool never_root general never_root 1
# shellcheck disable=SC2154
if [ "$enabled" -eq 0 ]; then
logger "service not enabled in $UCI_CONFIG"
return 1
fi
mkdir -p "/var/run/$USER"
chown $USER:$USER "/var/run/$USER"
procd_open_instance
procd_set_param command ${PROG} -c ${CONFIG} -f
if [ "$never_root" -eq 1 ]; then
procd_set_param user ${USER}
fi
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
}