packages/zabbix: use common CONFIGURE_ARGS var, cleanup
[openwrt/svn-archive/archive.git] / admin / zabbix / Makefile
1 #
2 # Copyright (C) 2006-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=zabbix
11 PKG_VERSION:=1.6
12 PKG_RELEASE:=2
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=@SF/zabbix
16 PKG_MD5SUM:=39d4c871439b1b4f0429964b4abbfc45
17
18 PKG_BUILD_DEPENDS:=libsqlite3
19 PKG_INSTALL:=1
20
21 include $(INCLUDE_DIR)/package.mk
22
23 define Package/zabbix/Default
24 SECTION:=admin
25 CATEGORY:=Administration
26 TITLE:=Zabbix
27 URL:=http://www.zabbix.com/
28 SUBMENU:=zabbix
29 DEPENDS:=+libcurl
30 endef
31
32 define Package/zabbix-agent
33 $(call Package/zabbix/Default)
34 TITLE+= agent
35 endef
36
37 define Package/zabbix-sender
38 $(call Package/zabbix/Default)
39 TITLE+= sender
40 endef
41
42 define Package/zabbix-server
43 $(call Package/zabbix/Default)
44 TITLE+= server
45 DEPENDS += +libsqlite3
46 endef
47
48
49 ifneq ($(SDK),)
50 CONFIG_PACKAGE_zabbix-server:=m
51 endif
52
53 CONFIGURE_ARGS+= \
54 --bindir="/usr/sbin" \
55 --enable-agent
56
57 ifneq ($(CONFIG_PACKAGE_zabbix-server),)
58 CONFIGURE_ARGS+= \
59 --enable-server \
60 --with-sqlite3="$(STAGING_DIR)/usr"
61 endif
62
63 MAKE_FLAGS += ARCH="linux"
64
65 define Package/zabbix-agent/conffiles
66 /etc/zabbix/zabbix_agentd.conf
67 endef
68
69 define Package/zabbix-agent/install
70 $(INSTALL_DIR) $(1)/usr/sbin
71 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zabbix_agentd $(1)/usr/sbin/
72 $(INSTALL_DIR) $(1)/etc/zabbix
73 $(INSTALL_CONF) ./files/zabbix_agentd.conf $(1)/etc/zabbix/
74 $(INSTALL_DIR) $(1)/etc/init.d
75 $(INSTALL_BIN) ./files/zabbix_agentd.init $(1)/etc/init.d/zabbix_agentd
76 endef
77
78 define Package/zabbix-agent/postinst
79 #!/bin/sh
80
81 name=zabbix
82 id=53
83
84 # do not change below
85 # check if we are on real system
86 if [ -z "$${IPKG_INSTROOT}" ]; then
87 # create copies of passwd and group, if we use squashfs
88 rootfs=`mount |awk '/root/ { print $$5 }'`
89 if [ "$$rootfs" = "squashfs" ]; then
90 if [ -h /etc/group ]; then
91 rm /etc/group
92 cp /rom/etc/group /etc/group
93 fi
94 if [ -h /etc/passwd ]; then
95 rm /etc/passwd
96 cp /rom/etc/passwd /etc/passwd
97 fi
98 fi
99
100 echo ""
101 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then
102 echo "adding group $$name to /etc/group"
103 echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group
104 fi
105
106 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then
107 echo "adding user $$name to /etc/passwd"
108 echo "$${name}:x:$${id}:$${id}:$${name}:/tmp/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd
109 fi
110
111 chown $${name} $${IPKG_INSTROOT}/etc/zabbix/zabbix_agentd.conf
112 fi
113
114 endef
115
116 define Package/zabbix-sender/install
117 $(INSTALL_DIR) $(1)/usr/sbin
118 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zabbix_sender $(1)/usr/sbin/
119 $(INSTALL_DIR) $(1)/etc/zabbix
120 endef
121
122 define Package/zabbix-server/conffiles
123 /etc/zabbix/zabbix_server.conf
124 endef
125
126 define Package/zabbix-server/install
127 $(INSTALL_DIR) $(1)/usr/sbin
128 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zabbix_server $(1)/usr/sbin/
129 $(INSTALL_DIR) $(1)/etc/zabbix
130 $(INSTALL_CONF) $(PKG_BUILD_DIR)/misc/conf/zabbix_server.conf $(1)/etc/zabbix/
131 endef
132
133 $(eval $(call BuildPackage,zabbix-agent))
134 $(eval $(call BuildPackage,zabbix-sender))
135 $(eval $(call BuildPackage,zabbix-server))