packages/zabbix: use new service functions, various other zabbix-agent fixes:
authorNicolas Thill <nico@openwrt.org>
Wed, 9 Nov 2011 19:49:06 +0000 (19:49 +0000)
committerNicolas Thill <nico@openwrt.org>
Wed, 9 Nov 2011 19:49:06 +0000 (19:49 +0000)
 * 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

admin/zabbix/Makefile
admin/zabbix/files/zabbix_agentd.conf
admin/zabbix/files/zabbix_agentd.init

index 7fd99a5d2f54b7120808f9ce37232605ff165dac..028ded1069afd1d86530fb77399178086e2a0c19 100644 (file)
@@ -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/
index 2787ccab8ab6aa57a32000f60b0a4d565a6b6827..4cc2f518e75447b95776a2679dd3349f6c744f98 100644 (file)
@@ -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
index a132a841a712497014c63ad457452a379f136d0d..3c70009d1a6c2a21343c0925af67f5e9bcb74205 100644 (file)
@@ -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
 }