[packages_10.03.2] pmacct: merge r28468, r28890
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Feb 2012 03:19:33 +0000 (03:19 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Feb 2012 03:19:33 +0000 (03:19 +0000)
SVN-Revision: 30167

admin/pmacct/Makefile
admin/pmacct/files/nfacctd.init
admin/pmacct/files/pmacctd.init
admin/pmacct/files/sfacctd.conf [new file with mode: 0644]
admin/pmacct/files/sfacctd.default [new file with mode: 0644]
admin/pmacct/files/sfacctd.init [new file with mode: 0644]
admin/pmacct/files/uacctd.init

index dcc64ee0ca6f58d9ea6fc2a3ca65fe9ec7a105e2..638fa637d22e02eb336ee4f5b3f24c322df5d26f 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=pmacct
 PKG_VERSION:=0.12.5
-PKG_RELEASE:=1
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://www.pmacct.net/
@@ -17,6 +17,11 @@ PKG_MD5SUM:=3d10f9301a17f034a0f221490a99a5d0
 
 PKG_BUILD_DEPENDS:=libpcap
 
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_CONFIG_DEPENDS:= \
+       CONFIG_IPV6 \
+
 include $(INCLUDE_DIR)/package.mk
 
 define Package/pmacct/Default
@@ -26,31 +31,15 @@ define Package/pmacct/Default
   URL:=http://www.pmacct.net/
 endef
 
-define Package/nfacctd/Default
+define Package/pmacct-client
   $(call Package/pmacct/Default)
-  TITLE:=NetFlow accounting daemon
-endef
-
-define Package/nfacctd
-  $(call Package/nfacctd/Default)
-endef
-
-define Package/nfacctd-mysql
-  $(call Package/nfacctd/Default)
-  TITLE+= with MySQL support
-  DEPENDS+= +libmysqlclient
-endef
-
-define Package/nfacctd-pgsql
-  $(call Package/nfacctd/Default)
-  TITLE+= with PostreSQL support
-  DEPENDS+= +libpq
+  TITLE:=Command-line client to gather data from the IMT plugin
+  VARIANT:=basic
 endef
 
-define Package/nfacctd-sqlite
-  $(call Package/nfacctd/Default)
-  TITLE+= with SQLite support
-  DEPENDS+= +libsqlite3
+define Package/nfacctd/Default
+  $(call Package/pmacct/Default)
+  TITLE:=NetFlow accounting daemon
 endef
 
 define Package/pmacctd/Default
@@ -59,26 +48,10 @@ define Package/pmacctd/Default
   TITLE:=IP pcap-based accounting daemon
 endef
 
-define Package/pmacctd
-  $(call Package/pmacctd/Default)
-endef
-
-define Package/pmacctd-mysql
-  $(call Package/pmacctd/Default)
-  TITLE+= with MySQL support
-  DEPENDS+= +libmysqlclient
-endef
-
-define Package/pmacctd-pgsql
-  $(call Package/pmacctd/Default)
-  TITLE+= with PostreSQL support
-  DEPENDS+= +libpq
-endef
-
-define Package/pmacctd-sqlite
-  $(call Package/pmacctd/Default)
-  TITLE+= with SQLite support
-  DEPENDS+= +libsqlite3
+define Package/sfacctd/Default
+  $(call Package/pmacct/Default)
+  DEPENDS+= +libpcap
+  TITLE:=sFlow accounting daemon
 endef
 
 define Package/uacctd/Default
@@ -87,155 +60,125 @@ define Package/uacctd/Default
   TITLE:=ulog accounting daemon
 endef
 
-define Package/uacctd
-  $(call Package/pmacctd/Default)
-endef
-
-define Package/uacctd-mysql
-  $(call Package/pmacctd/Default)
-  TITLE+= with MySQL support
-  DEPENDS+= +libmysqlclient
-endef
-
-define Package/uacctd-pgsql
-  $(call Package/pmacctd/Default)
-  TITLE+= with PostreSQL support
-  DEPENDS+= +libpq
-endef
-
-define Package/uacctd-sqlite
-  $(call Package/pmacctd/Default)
-  TITLE+= with SQLite support
-  DEPENDS+= +libsqlite3
-endef
-
-define Package/pmacct-client
-  $(call Package/pmacct/Default)
-  TITLE:=Command-line client to gather data from the IMT plugin
-endef
-
-define Compile/Template
-
-$(PKG_BUILD_DIR)/nfacctd$(1) $(PKG_BUILD_DIR)/pmacctd$(1) $(PKG_BUILD_DIR)/uacctd$(1): $(STAMP_CONFIGURED)
-       -$(MAKE) -C $(PKG_BUILD_DIR) distclean
-       $(call Build/Configure/Default, \
-               --with-pcap-includes="$(STAGING_DIR)/usr/include" \
-               --with-pcap-libs="$(STAGING_DIR)/usr/lib" \
-               --enable-ulog \
-               $(2) \
-               ,\
-               LIBS="-lz" \
-               ,,\
-       );
-       $(MAKE) -C $(PKG_BUILD_DIR) \
-               all
-       mv -f $(PKG_BUILD_DIR)/src/nfacctd $(PKG_BUILD_DIR)/nfacctd$(1)
-       mv -f $(PKG_BUILD_DIR)/src/pmacctd $(PKG_BUILD_DIR)/pmacctd$(1)
-       mv -f $(PKG_BUILD_DIR)/src/uacctd $(PKG_BUILD_DIR)/uacctd$(1)
-
-$(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/nfacctd$(1) $(PKG_BUILD_DIR)/pmacctd$(1) $(PKG_BUILD_DIR)/uacctd$(1)
 
-endef
+CONFIGURE_ARGS+= \
+       $(call autoconf_bool,CONFIG_IPV6,ipv6) \
+       --with-pcap-includes="$(STAGING_DIR)/usr/include" \
+       --with-pcap-libs="$(STAGING_DIR)/usr/lib" \
+       --enable-ulog \
 
+ifeq ($(BUILD_VARIANT),basic)
 
-define Install/Template
-
-define Package/$(1)$(2)/conffiles
-/etc/default/$(1)
-/etc/$(1).conf
-endef
-
-define Package/$(1)$(2)/install
-       $(INSTALL_DIR) $$(1)/usr/sbin
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(1)$(2) $$(1)/usr/sbin/$(1)
-       $(INSTALL_DIR) $$(1)/etc
-       $(INSTALL_DATA) ./files/$(1).conf $$(1)/etc/
-       $(INSTALL_DIR) $$(1)/etc/default
-       $(INSTALL_DATA) ./files/$(1).default $$(1)/etc/default/$(1)
-       $(INSTALL_DIR) $$(1)/etc/init.d
-       $(INSTALL_BIN) ./files/$(1).init $$(1)/etc/init.d/$(1)
-endef
-
-endef
-
-ifneq ($(SDK)$(CONFIG_PACKAGE_nfacctd)$(CONFIG_PACKAGE_pmacctd)$(CONFIG_PACKAGE_uacctd),)
-  define Compile/pmacct/basic
-    $(call Compile/Template,, \
+  CONFIGURE_ARGS += \
        --disable-mysql \
        --disable-pgsql \
        --disable-sqlite3 \
-    )
-    $(call Install/Template,nfacctd,)
-    $(call Install/Template,pmacctd,)
-       $(call Install/Template,uacctd,)
-  endef
+
 endif
-$(eval $(Compile/pmacct/basic))
 
-ifneq ($(SDK)$(CONFIG_PACKAGE_nfacctd-mysql)$(CONFIG_PACKAGE_pmacctd-mysql)$(CONFIG_PACKAGE_uacctd-mysql),)
-  define Compile/pmacct/mysql
-    $(call Compile/Template,-mysql, \
+ifeq ($(BUILD_VARIANT),mysql)
+
+  CONFIGURE_ARGS += \
        --enable-mysql \
        --with-mysql-includes="$(STAGING_DIR)/usr/include" \
        --with-mysql-libs="$(STAGING_DIR)/usr/lib/mysql" \
-    )
-    $(call Install/Template,nfacctd,-mysql)
-    $(call Install/Template,pmacctd,-mysql)
-       $(call Install/Template,uacctd,-mysql)
-  endef
+       --disable-pgsql \
+       --disable-sqlite3 \
+
+  CONFIGURE_VARS+= \
+       LIBS="-lz" \
+
 endif
-$(eval $(Compile/pmacct/mysql))
 
-ifneq ($(SDK)$(CONFIG_PACKAGE_nfacctd-pgsql)$(CONFIG_PACKAGE_pmacctd-pgsql)$(CONFIG_PACKAGE_uacctd-pgsql),)
-  define Compile/pmacct/pgsql
-    $(call Compile/Template,-pgsql, \
+ifeq ($(BUILD_VARIANT),pgsql)
+
+  CONFIGURE_ARGS += \
+       --disable-mysql \
        --enable-pgsql \
        --with-pgsql-includes="$(STAGING_DIR)/usr/include" \
        --with-pgsql-libs="$(STAGING_DIR)/usr/lib" \
-    )
-    $(call Install/Template,nfacctd,-pgsql)
-    $(call Install/Template,pmacctd,-pgsql)
-       $(call Install/Template,uacctd,-pgsql)
-  endef
+       --disable-sqlite3 \
+
 endif
-$(eval $(Compile/pmacct/pgsql))
 
-ifneq ($(SDK)$(CONFIG_PACKAGE_nfacctd-sqlite)$(CONFIG_PACKAGE_pmacctd-sqlite)$(CONFIG_PACKAGE_uacctd-sqlite),)
-  define Compile/pmacct/sqlite
-    $(call Compile/Template,-sqlite, \
+ifeq ($(BUILD_VARIANT),sqlite)
+
+  CONFIGURE_ARGS += \
+       --disable-mysql \
+       --disable-pgsql \
        --enable-sqlite3 \
        --with-sqlite3-includes="$(STAGING_DIR)/usr/include" \
        --with-sqlite3-libs="$(STAGING_DIR)/usr/lib" \
-    )
-    $(call Install/Template,nfacctd,-sqlite)
-    $(call Install/Template,pmacctd,-sqlite)
-       $(call Install/Template,uacctd,-sqlite)
-  endef
+
 endif
-$(eval $(Compile/pmacct/sqlite))
 
-define Build/Configure
-endef
 
 define Build/Compile
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               DESTDIR="$(PKG_INSTALL_DIR)" \
+               all install
 endef
 
+
 define Package/pmacct-client/install
        $(INSTALL_DIR) $(1)/usr/sbin
        $(CP) $(PKG_BUILD_DIR)/src/pmacct $(1)/usr/sbin/
 endef
 
-$(eval $(call BuildPackage,nfacctd))
-$(eval $(call BuildPackage,nfacctd-mysql))
-$(eval $(call BuildPackage,nfacctd-pgsql))
-$(eval $(call BuildPackage,nfacctd-sqlite))
-$(eval $(call BuildPackage,pmacctd))
-$(eval $(call BuildPackage,pmacctd-mysql))
-$(eval $(call BuildPackage,pmacctd-pgsql))
-$(eval $(call BuildPackage,pmacctd-sqlite))
+
+# $(1): build variant {basic,mysql,pgsql,sqlite}
+# $(2): package name prefix {nfacctd,pmacctd,sfacctd,uacctd}
+# $(3): package name suffix {,-mysql,-pgsql,-sqlite}
+# $(4): additional title (with MySQL support, ...)
+# $(5): additional dependencies (+libmysqlclient, ...)
+
+define BuildPackage/Template
+
+  define Package/$(2)$(3)
+    $(call Package/$(2)/Default)
+    DEPENDS+= $(5)
+    TITLE+= $(4)
+    VARIANT:=$(1)
+  endef
+
+  define Package/$(2)$(3)/conffiles
+    /etc/default/$(2)
+    /etc/$(2).conf
+  endef
+
+  define Package/$(2)$(3)/install
+       $(INSTALL_DIR) $$(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/$(2) $$(1)/usr/sbin/
+       $(INSTALL_DIR) $$(1)/etc
+       $(INSTALL_DATA) ./files/$(2).conf $$(1)/etc/
+       $(INSTALL_DIR) $$(1)/etc/default
+       $(INSTALL_DATA) ./files/$(2).default $$(1)/etc/default/$(2)
+       $(INSTALL_DIR) $$(1)/etc/init.d
+       $(INSTALL_BIN) ./files/$(2).init $$(1)/etc/init.d/$(2)
+  endef
+
+  $$(eval $$(call BuildPackage,$(2)$(3)))
+
+endef
+
 $(eval $(call BuildPackage,pmacct-client))
-$(eval $(call BuildPackage,uacctd))
-$(eval $(call BuildPackage,uacctd-mysql))
-$(eval $(call BuildPackage,uacctd-pgsql))
-$(eval $(call BuildPackage,uacctd-sqlite))
 
+$(eval $(call BuildPackage/Template,basic,nfacctd,,,))
+$(eval $(call BuildPackage/Template,basic,pmacctd,,,))
+$(eval $(call BuildPackage/Template,basic,sfacctd,,,))
+$(eval $(call BuildPackage/Template,basic,uacctd,,,))
+
+$(eval $(call BuildPackage/Template,mysql,nfacctd,-mysql,with MySQL support,+libmysqlclient))
+$(eval $(call BuildPackage/Template,mysql,pmacctd,-mysql,with MySQL support,+libmysqlclient))
+$(eval $(call BuildPackage/Template,mysql,sfacctd,-mysql,with MySQL support,+libmysqlclient))
+$(eval $(call BuildPackage/Template,mysql,uacctd,-mysql,with MySQL support,+libmysqlclient))
+
+$(eval $(call BuildPackage/Template,pgsql,nfacctd,-pgsql,with PostgreSQL support,+libpq))
+$(eval $(call BuildPackage/Template,pgsql,pmacctd,-pgsql,with PostgreSQL support,+libpq))
+$(eval $(call BuildPackage/Template,pgsql,sfacctd,-pgsql,with PostgreSQL support,+libpq))
+$(eval $(call BuildPackage/Template,pgsql,uacctd,-pgsql,with PostgreSQL support,+libpq))
+
+$(eval $(call BuildPackage/Template,sqlite,nfacctd,-sqlite,with SQLite support,+libsqlite3))
+$(eval $(call BuildPackage/Template,sqlite,pmacctd,-sqlite,with SQLite support,+libsqlite3))
+$(eval $(call BuildPackage/Template,sqlite,sfacctd,-sqlite,with SQLite support,+libsqlite3))
+$(eval $(call BuildPackage/Template,sqlite,uacctd,-sqlite,with SQLite support,+libsqlite3))
index e1113571c269085d3a37aa2542b194ecb815440a..66b9021919d16e052ca488189a6c4a382b372e59 100644 (file)
@@ -1,18 +1,19 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
+
 START=50
 
-BIN=nfacctd
-DEFAULT=/etc/default/$BIN
-RUN_D=/var/run
-PID_F=$RUN_D/$BIN.pid
+SERVICE_USE_PID=1
+
+PROG="nfacctd"
+DEFAULT="/etc/default/$PROG"
+COMMAND="/usr/sbin/$PROG"
 
 start() {
        [ -f $DEFAULT ] && . $DEFAULT
-       mkdir -p $RUN_D
-       $BIN $OPTIONS
+       service_start $COMMAND $OPTIONS
 }
 
 stop() {
-       [ -f $PID_F ] && kill -INT $(cat $PID_F)
+       service_stop $COMMAND
 }
index a57c5817bf6830804a7536848e8c250648bfa467..3d75bcfa9394ac464a033e3dc345d51ec3ac9f07 100644 (file)
@@ -1,18 +1,19 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
+
 START=50
 
-BIN=pmacctd
-DEFAULT=/etc/default/$BIN
-RUN_D=/var/run
-PID_F=$RUN_D/$BIN.pid
+SERVICE_USE_PID=1
+
+PROG="pmacctd"
+DEFAULT="/etc/default/$PROG"
+COMMAND="/usr/sbin/$PROG"
 
 start() {
        [ -f $DEFAULT ] && . $DEFAULT
-       mkdir -p $RUN_D
-       $BIN $OPTIONS
+       service_start $COMMAND $OPTIONS
 }
 
 stop() {
-       [ -f $PID_F ] && kill -INT $(cat $PID_F)
+       service_stop $COMMAND
 }
diff --git a/admin/pmacct/files/sfacctd.conf b/admin/pmacct/files/sfacctd.conf
new file mode 100644 (file)
index 0000000..3d25e54
--- /dev/null
@@ -0,0 +1,27 @@
+!
+! sfacctd configuration example
+!
+! debug: true
+daemonize: true
+pidfile: /var/run/sfacctd.pid
+! aggregate_filter[dummy]: src net 192.168.0.0/16
+aggregate: src_host, dst_host
+! plugin_buffer_size: 1024
+! sfacctd_port: 5678
+plugins: memory
+imt_buckets: 65537
+imt_mem_pools_size: 65536
+! imt_mem_pools_number: 0
+! plugins: mysql
+! plugins: pgsql
+! plugins: sqlite3
+! sql_db: pmacct
+! sql_table: acct
+! sql_table_version: 2
+! sql_passwd: arealsmartpwd
+! sql_user: pmacct
+! sql_refresh_time: 90
+! sql_optimize_clauses: true
+! sql_history: 10m
+! sql_history_roundoff: mh
+! networks_file: ./networks.example
diff --git a/admin/pmacct/files/sfacctd.default b/admin/pmacct/files/sfacctd.default
new file mode 100644 (file)
index 0000000..abd0c34
--- /dev/null
@@ -0,0 +1 @@
+OPTIONS="-f /etc/sfacctd.conf"
diff --git a/admin/pmacct/files/sfacctd.init b/admin/pmacct/files/sfacctd.init
new file mode 100644 (file)
index 0000000..16468d4
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=50
+
+SERVICE_USE_PID=1
+
+PROG="sfacctd"
+DEFAULT="/etc/default/$PROG"
+COMMAND="/usr/sbin/$PROG"
+
+start() {
+       [ -f $DEFAULT ] && . $DEFAULT
+       service_start $COMMAND $OPTIONS
+}
+
+stop() {
+       service_stop $COMMAND
+}
index a4239ad34c95f88bab9521988dd5378fcc57aaac..39b27baf361f2ef87ae9e2b9d486154b2dcda915 100644 (file)
@@ -1,18 +1,19 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
+
 START=50
 
-BIN=uacctd
-DEFAULT=/etc/default/$BIN
-RUN_D=/var/run
-PID_F=$RUN_D/$BIN.pid
+SERVICE_USE_PID=1
+
+PROG="uacctd"
+DEFAULT="/etc/default/$PROG"
+COMMAND="/usr/sbin/$PROG"
 
 start() {
        [ -f $DEFAULT ] && . $DEFAULT
-       mkdir -p $RUN_D
-       $BIN $OPTIONS
+       service_start $COMMAND $OPTIONS
 }
 
 stop() {
-       [ -f $PID_F ] && kill -INT $(cat $PID_F)
+       service_stop $COMMAND
 }