From: Nicolas Thill Date: Wed, 9 Nov 2011 19:49:06 +0000 (+0000) Subject: packages/zabbix: use new service functions, various other zabbix-agent fixes: X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=d99bc513372804064cf4bea139ffb31b53cb99ff;p=openwrt%2Fsvn-archive%2Fpackages.git packages/zabbix: use new service functions, various other zabbix-agent fixes: * move user/group creation from postinst to initscript * use /var/run/zabbix directory for pid file * use /var/log/zabbix directory for log file * set correct ownership and perms for both directories SVN-Revision: 28892 --- diff --git a/admin/zabbix/Makefile b/admin/zabbix/Makefile index 7fd99a5d2..028ded106 100644 --- a/admin/zabbix/Makefile +++ b/admin/zabbix/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2006-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zabbix PKG_VERSION:=1.6 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/zabbix @@ -75,44 +75,6 @@ define Package/zabbix-agent/install $(INSTALL_BIN) ./files/zabbix_agentd.init $(1)/etc/init.d/zabbix_agentd endef -define Package/zabbix-agent/postinst -#!/bin/sh - -name=zabbix -id=53 - -# do not change below -# check if we are on real system -if [ -z "$${IPKG_INSTROOT}" ]; then - # create copies of passwd and group, if we use squashfs - rootfs=`mount |awk '/root/ { print $$5 }'` - if [ "$$rootfs" = "squashfs" ]; then - if [ -h /etc/group ]; then - rm /etc/group - cp /rom/etc/group /etc/group - fi - if [ -h /etc/passwd ]; then - rm /etc/passwd - cp /rom/etc/passwd /etc/passwd - fi - fi - - echo "" - if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then - echo "adding group $$name to /etc/group" - echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group - fi - - if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then - echo "adding user $$name to /etc/passwd" - echo "$${name}:x:$${id}:$${id}:$${name}:/tmp/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd - fi - - chown $${name} $${IPKG_INSTROOT}/etc/zabbix/zabbix_agentd.conf -fi - -endef - define Package/zabbix-sender/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zabbix_sender $(1)/usr/sbin/ diff --git a/admin/zabbix/files/zabbix_agentd.conf b/admin/zabbix/files/zabbix_agentd.conf index 2787ccab8..4cc2f518e 100644 --- a/admin/zabbix/files/zabbix_agentd.conf +++ b/admin/zabbix/files/zabbix_agentd.conf @@ -57,12 +57,12 @@ DebugLevel=3 # Name of PID file -PidFile=/tmp/zabbix_agentd.pid +PidFile=/var/run/zabbix/zabbix_agentd.pid # Name of log file. # If not set, syslog will be used -LogFile=/tmp/zabbix_agentd.log +LogFile=/var/log/zabbix/zabbix_agentd.log # Spend no more than Timeout seconds on processing # Must be between 1 and 30 diff --git a/admin/zabbix/files/zabbix_agentd.init b/admin/zabbix/files/zabbix_agentd.init index a132a841a..3c70009d1 100644 --- a/admin/zabbix/files/zabbix_agentd.init +++ b/admin/zabbix/files/zabbix_agentd.init @@ -1,21 +1,25 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2008 OpenWrt.org +# Copyright (C) 2008-2011 OpenWrt.org + START=60 +SERVICE_PID_FILE=/var/run/zabbix/zabbix_agentd.pid + start() { - [ -f /etc/zabbix/zabbix_agentd.conf ] || { - echo "/etc/zabbix/zabbix_agentd.conf does not exist !"; - exit 0; - }; - [ -x /usr/sbin/zabbix_agentd ] && /usr/sbin/zabbix_agentd + [ -f /etc/zabbix/zabbix_agentd.conf ] || return 1 + user_exists zabbix 53 || user_add zabbix 53 + group_exists zabbix 53 || group_add zabbix 53 + [ -d /var/log/zabbix ] || { + mkdir -m0755 -p /var/log/zabbix + chown zabbix:zabbix /var/log/zabbix + } + [ -d /var/run/zabbix ] || { + mkdir -m0755 -p /var/run/zabbix + chown zabbix:zabbix /var/run/zabbix + } + service_start /usr/sbin/zabbix_agentd } stop() { - killall zabbix_agentd -} - -restart() { - stop - sleep 1 - start + service_stop /usr/sbin/zabbix_agentd }