[package] merge vnstati to vnstat package, use tarball's configuration file, remove...
authorFlorian Fainelli <florian@openwrt.org>
Thu, 4 Jun 2009 09:57:46 +0000 (09:57 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Thu, 4 Jun 2009 09:57:46 +0000 (09:57 +0000)
SVN-Revision: 16327

net/vnstat/Makefile
net/vnstat/files/vnstat-uci.conf [new file with mode: 0644]
net/vnstat/files/vnstat.conf
net/vnstat/files/vnstat.init
net/vnstati/Makefile [deleted file]

index c36f7305889a753c793cb23b7fc11e582440ae96..4b82f75bab54f9f7d22b0a614df56c5e03dda6e2 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=vnstat
 PKG_VERSION:=1.7
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://humdi.net/vnstat
@@ -17,13 +17,17 @@ PKG_MD5SUM:=e5788e8122e34f2c93561e2a84c19432
 
 include $(INCLUDE_DIR)/package.mk
 
-define Package/vnstat
+define Package/vnstat/Default
   SECTION:=net
   CATEGORY:=Network
-  TITLE:=Console-based network traffic monitor
   URL:=http://humdi.net/vnstat/
 endef
 
+define Package/vnstat
+$(call Package/vnstat/Default)
+  TITLE:=Console-based network traffic monitor
+endef
+
 define Package/vnstat/description
        vnStat is a network traffic monitor for Linux that keeps a log of daily 
        network traffic for the selected interface(s). vnStat isn't a packet 
@@ -31,25 +35,62 @@ define Package/vnstat/description
        so vnStat can be used without root permissions.
 endef
 
+define Package/vnstati
+$(call Package/vnstat/Default)
+  DEPENDS+=vnstat +libgd
+  TITLE:=PNG image output support for vnStat
+endef
+
+define Package/vnstati/description
+       The purpose of vnstati is to provide image output support for statistics
+       collected using vnstat(1). However, the image file format is limited to
+       png. All basic outputs of vnStat are supported excluding live traffic
+       features. The image can be outputted either to a file or to standard
+       output.
+endef
+
 define Package/vnstat/conffiles
+/etc/vnstat.conf
 /etc/config/vnstat
 endef
 
-define Build/Compile
+define Build/Compile/vnstat
        $(MAKE) -C $(PKG_BUILD_DIR) \
                $(TARGET_CONFIGURE_OPTS) \
                CFLAGS="$(TARGET_CFLAGS)"
 endef
 
+define Build/Compile/vnstati
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               $(TARGET_CONFIGURE_OPTS) \
+               CFLAGS="$(TARGET_CPPFLAGS)" \
+               LDFLAGS="$(TARGET_LDFLAGS) -Wl,-rpath-link,$(STAGING_DIR)/usr/lib" \
+               all
+endef
+
+define Build/Compile
+$(call Build/Compile/vnstat)
+$(call Build/Compile/vnstati)
+endef
+
 define Package/vnstat/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstat $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstatd $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/etc
+       $(INSTALL_DATA) ./files/vnstat.conf $(1)/etc
        $(INSTALL_DIR) $(1)/etc/config
-       $(INSTALL_DATA) ./files/vnstat.conf $(1)/etc/config/vnstat
+       $(INSTALL_DATA) ./files/vnstat-uci.conf $(1)/etc/config/vnstat
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/vnstat.init $(1)/etc/init.d/vnstat
 endef
 
+define Package/vnstati/install 
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstati $(1)/usr/bin/
+endef
+
 define Package/vnstat/postinst
 #!/bin/sh
 BIN_REL=/usr/bin/vnstat
@@ -64,8 +105,9 @@ if [ -n $$IFACE_WAN ]; then
        [ -e $$LIB_D/$$IFACE_WAN ] || ( [ -x $$BIN ] && $$BIN -u -i $$IFACE_WAN )
 fi
 grep -q "$$BIN_REL -u" $$CRONTAB 2>/dev/null
-[ $$? -ne 0 ] && echo "*/30 * * * *    if [ -x $$BIN_REL ] && [ \`ls $$LIB_D_REL | wc -l\` -ge 1 ]; then $$BIN_REL -u; fi" >> $$CRONTAB
+[ $$? -eq 0 ] && sed -i -e "/\/usr\/bin\/vnstat -u/d" $$CRONTAB
 true
 endef
 
 $(eval $(call BuildPackage,vnstat))
+$(eval $(call BuildPackage,vnstati))
diff --git a/net/vnstat/files/vnstat-uci.conf b/net/vnstat/files/vnstat-uci.conf
new file mode 100644 (file)
index 0000000..44c02c2
--- /dev/null
@@ -0,0 +1,4 @@
+config interface               wan
+       option enabled          0
+       option remote_host      <webserver>
+       option remote_path      <directory>
index 44c02c2d00358d9ffa28c4855dda50105c9a1a6e..14f5e2c1da89daf318552a15d01c4f41ac8adabd 100644 (file)
@@ -1,4 +1,98 @@
-config interface               wan
-       option enabled          0
-       option remote_host      <webserver>
-       option remote_path      <directory>
+# vnStat 1.7 config file
+##
+
+# location of the database directory
+DatabaseDir "/var/lib/vnstat"
+
+# locale (LC_ALL)
+Locale "en_US"
+
+# on which day should months change
+MonthRotate 1
+
+# date output formats for -d, -m, -t and -w
+# see 'man date' for control codes
+DayFormat    "%d.%m."
+MonthFormat  "%b '%y"
+TopFormat    "%d.%m.%y"
+
+# characters used for visuals
+RXCharacter       "%"
+TXCharacter       ":"
+RXHourCharacter   "r"
+TXHourCharacter   "t"
+
+# how units are prefixed when traffic is shown
+# 0 = IEC standard prefixes (KiB/MiB/GiB/TiB)
+# 1 = old style binary prefixes (KB/MB/GB/TB)
+UnitMode 0
+
+# default interface
+Interface "eth0"
+
+# maximum bandwidth (Mbit) for all interfaces, 0 = disable feature
+# (unless interface specific limit is given)
+MaxBandwidth 100
+
+# interface specific limits
+#  example 8Mbit limit for eth0 (remove # to activate):
+#MaxBWeth0 8
+
+# how many seconds should sampling for -tr take by default
+Sampletime 5
+
+# default query mode
+# 0 = normal, 1 = days, 2 = months, 3 = top10
+# 4 = dumpdb, 5 = short, 6 = weeks, 7 = hours
+QueryMode 0
+
+# filesystem disk space check (1 = enabled, 0 = disabled)
+CheckDiskSpace 1
+
+# database file locking (1 = enabled, 0 = disabled)
+UseFileLocking 1
+
+# how much the boot time can variate between updates (seconds)
+BootVariation 15
+
+
+# vnstatd
+##
+
+# how often (in seconds) interface data is updated
+UpdateInterval 60
+
+# how often (in seconds) interface status changes are checked
+PollInterval 30
+
+# how often (in minutes) interface data is saved to file
+SaveInterval 30
+
+# enable / disable logging (0 = disabled, 1 = logfile, 2 = syslog)
+UseLogging 2
+
+# file used for logging if UseLogging is set to 1
+LogFile "/var/log/vnstat.log"
+
+# file used as daemon pid / lock file
+PidFile "/var/run/vnstat.pid"
+
+
+# vnstati
+##
+
+HeaderFormat    "%d.%m.%Y %H:%M"
+
+# colors
+CBackground     "FFFFFF"
+CEdge           "AEAEAE"
+CHeader         "606060"
+CHeaderTitle    "FFFFFF"
+CHeaderDate     "FFFFFF"
+CText           "000000"
+CLine           "B0B0B0"
+CLineL          "-"
+CRx             "92CF00"
+CTx             "606060"
+CRxD            "-"
+CTxD            "-"
index 07db20cba863daca068409a24f03affa12d9952a..5632c6a777a5f8f6acbeb463bd193e0f06aa28be 100644 (file)
@@ -4,6 +4,9 @@
 START=99
 LIB_D=/var/lib/vnstat
 WWW_D=/www/vnstat
+RUN_D=/var/run
+PID_F=$RUN_D/vnstat.pid
+VNSTATD_BIN=/usr/sbin/vnstatd
 
 system_config() {
        local cfg="$1"
@@ -18,30 +21,27 @@ do_download() {
 
        local cfg="$1"
 
-       config_get ifname "$cfg" "ifname"
+       config_get ifname "$cfg" ifname
        [ -n "$ifname" ] || return 0
        [ -e $LIB_D/$ifname ] && return 0
 
-       config_get_bool enabled "$cfg" "enabled" "1"
-       if [ "$enabled" -gt 0 ]; then
-               config_get remote_path "$cfg" "remote_path"
-               [ -n "$remote_path" ] || return 0
-               config_get remote_host "$cfg" "remote_host"
+       config_get_bool enabled "$cfg" enabled '1'
+       [ "$enabled" -gt 0 ] && {
+               config_get remote_host "$cfg" remote_host
                [ -n "$remote_host" ] || return 0
-
-               [ -x /usr/bin/wget ] && download_command="wget http://$remote_host/$remote_path/${hostname}_$ifname -O $LIB_D/$ifname"
-               [ -n "$download_command" ] || return 0
+               config_get remote_path "$cfg" remote_path
+               [ -n "$remote_path" ] || return 0
 
                while [ ! -e $LIB_D/$ifname ]; do
-                       $download_command 2>/dev/null
+                       wget http://$remote_host/$remote_path/${hostname}_$ifname -O $LIB_D/$ifname 2>/dev/null
                        [ -e $LIB_D/$ifname ] && {
-                               logger -s -t "vnstat" "Successfully downloaded ${ifname}'s vnStat database backup"
-                               [ -x /bin/ln ] && ln -sf $LIB_D/$ifname $WWW_D/$ifname
+                               logger -t "vnstat" "Successfully downloaded ${ifname}'s vnStat database backup"
+                               [ -L $WWW_D/$ifname ] || ln -s $LIB_D/$ifname $WWW_D/$ifname
                                return 0
                        }
                        sleep 30
                done
-       fi
+       }
 }
 
 start() {
@@ -53,4 +53,15 @@ start() {
 
        config_load vnstat
        config_foreach do_download interface
+
+       [ ! -f $PID_F ] && $VNSTATD_BIN -d
 }
+
+stop() {
+       [ -f $PID_F ] && kill $(cat $PID_F)
+}
+
+reload() {
+       [ -f $PID_F ] && kill -HUP $(cat $PID_F)
+}
+
diff --git a/net/vnstati/Makefile b/net/vnstati/Makefile
deleted file mode 100644 (file)
index f11b6af..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-# 
-# Copyright (C) 2008-2009 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=vnstati
-PKG_VERSION:=beta3
-PKG_RELEASE:=1
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=http://humdi.net/vnstat
-PKG_MD5SUM:=5652b955e16716cec48da464b083c76f
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/vnstati
-  SECTION:=net
-  CATEGORY:=Network
-  DEPENDS:=+vnstat +libgd
-  TITLE:=vnStat image output - png image output support for vnStat
-  URL:=http://humdi.net/vnstat/
-endef
-
-define Package/vnstati/description
-       The purpose of vnstati is to provide image output support for statistics
-       collected using vnstat(1). However, the image file format is limited to
-       png. All basic outputs of vnStat are supported excluding live traffic
-       features. The image can be outputted either to a file or to standard
-       output.
-endef
-
-define Build/Compile
-       $(MAKE) -C $(PKG_BUILD_DIR) \
-               $(TARGET_CONFIGURE_OPTS) \
-               CFLAGS+="$(TARGET_CPPFLAGS) $(TARGET_LDFLAGS) -Wl,-rpath-link,$(STAGING_DIR)/usr/lib"
-endef
-
-define Package/vnstati/install 
-       $(INSTALL_DIR) $(1)/usr/bin
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/vnstati $(1)/usr/bin/
-endef
-
-$(eval $(call BuildPackage,vnstati))