add darkstat
authorJens Muecke <jens@nons.de>
Sun, 22 Apr 2007 20:09:05 +0000 (20:09 +0000)
committerJens Muecke <jens@nons.de>
Sun, 22 Apr 2007 20:09:05 +0000 (20:09 +0000)
SVN-Revision: 7036

net/darkstat/Makefile [new file with mode: 0644]
net/darkstat/files/darkstat.conf [new file with mode: 0644]
net/darkstat/files/darkstat.init [new file with mode: 0755]

diff --git a/net/darkstat/Makefile b/net/darkstat/Makefile
new file mode 100644 (file)
index 0000000..d693343
--- /dev/null
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id: $
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=darkstat
+PKG_VERSION:=3.0.540
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://dmr.ath.cx/net/darkstat
+PKG_MD5SUM:=498256c667b4fa79a551ac3626a2ba86
+PKG_CAT:=bzcat
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/darkstat
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=+libpcap
+  TITLE:=Network bandwith monitor
+  DESCRIPTION:=\
+       A free open source utility for bandwith monitoring \
+       over web
+  URL:=http://dmr.ath.cx/net/darkstat/
+endef
+
+define Build/Compile   
+       mkdir -p $(PKG_INSTALL_DIR)
+       $(HOSTCC) $(PKG_BUILD_DIR)/static/c-ify.c \
+               -o $(PKG_BUILD_DIR)/c-ify
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               DESTDIR="$(PKG_INSTALL_DIR)" \
+               all install
+endef
+
+define Package/darkstat/install        
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/darkstat $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/darkstat.init $(1)/etc/init.d/darkstat
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/darkstat.conf $(1)/etc/config/darkstat
+endef
+
+$(eval $(call BuildPackage,darkstat))
diff --git a/net/darkstat/files/darkstat.conf b/net/darkstat/files/darkstat.conf
new file mode 100644 (file)
index 0000000..f83760e
--- /dev/null
@@ -0,0 +1,4 @@
+config darkstat
+       option interface 'lan'
+#      option httpaddr  '0.0.0.0'
+#      option httpport  '667'
diff --git a/net/darkstat/files/darkstat.init b/net/darkstat/files/darkstat.init
new file mode 100755 (executable)
index 0000000..acdd286
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007 OpenWrt.org
+
+START=60
+BIN=darkstat
+RUN_D=/var/empty
+PID_F=$RUN_D/$BIN.pid
+
+start() {
+       mkdir -p $RUN_D
+       config_load darkstat
+       config_foreach start_darkstat darkstat
+}
+
+start_darkstat() {
+       local cfg="$1"
+       config_get interface "$cfg" interface
+       config_get httpaddr "$cfg" httpaddr
+       config_get httpport "$cfg" httpport
+
+       include /lib/network
+       scan_interfaces
+       config_get ifname "$interface" ifname
+       
+       $BIN -d -i "${ifname:-$interface}" \
+               ${httpaddr:+-b "$httpaddr"}  \
+               ${httpport:+-p "$httpport"}
+}
+       
+
+stop() {
+       ps aux | grep nobody | grep darkstat |  awk '{print }' | \
+               xargs kill 2> /dev/null
+}
+