openwrt-packages/admin/zabbix/files/zabbix_agentd.init

34 lines
825 B
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2011 OpenWrt.org
START=60
PROG=/usr/sbin/zabbix_agentd
CONFIG=/etc/zabbix_agentd.conf
SERVICE_PID_FILE=/var/run/zabbix_agentd.pid
start() {
# Sometimes the agentd config was installed in /etc/zabbix/zabbix_agentd.conf
[ -f /etc/zabbix/zabbix_agentd.conf ] && mv /etc/zabbix/zabbix_agentd.conf ${CONFIG}
[ -f ${CONFIG} ] || return 1
grep -q "^PidFile=${SERVICE_PID_FILE}" ${CONFIG} || {
logger -s -t ${CONFIG} -p daemon.error "Only \"PidFile=${SERVICE_PID_FILE}\" supported"
return 1
}
grep -q "^AllowRoot=1" ${CONFIG} || {
user_exists zabbix 53 || user_add zabbix 53
group_exists zabbix 53 || group_add zabbix 53
touch ${SERVICE_PID_FILE}
chown zabbix:zabbix ${SERVICE_PID_FILE}
}
service_start ${PROG} -c ${CONFIG}
}
stop() {
service_stop ${PROG}
}