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