zabbix: correct pidfile und update initscript
[openwrt/svn-archive/archive.git] / admin / zabbix / files / zabbix_agentd.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008-2011 OpenWrt.org
3
4 START=60
5
6 PROG=/usr/sbin/zabbix_agentd
7 CONFIG=/etc/zabbix_agentd.conf
8 SERVICE_PID_FILE=/var/run/zabbix_agentd.pid
9
10 start() {
11 # Sometimes the agentd config was installed in /etc/zabbix/zabbix_agentd.conf
12 [ -f /etc/zabbix/zabbix_agentd.conf ] && mv /etc/zabbix/zabbix_agentd.conf ${CONFIG}
13
14 [ -f ${CONFIG} ] || return 1
15
16 grep -q "^PidFile=${SERVICE_PID_FILE}" ${CONFIG} || {
17 logger -s -t ${CONFIG} -p daemon.error "Only \"PidFile=${SERVICE_PID_FILE}\" supported"
18 return 1
19 }
20
21 grep -q "^AllowRoot=1" ${CONFIG} || {
22 user_exists zabbix 53 || user_add zabbix 53
23 group_exists zabbix 53 || group_add zabbix 53
24 touch ${SERVICE_PID_FILE}
25 chown zabbix:zabbix ${SERVICE_PID_FILE}
26 }
27
28 service_start ${PROG} -c ${CONFIG}
29 }
30
31 stop() {
32 service_stop ${PROG}
33 }