From 8ad57d2e030af888a6112b07206be66241dbeb1d Mon Sep 17 00:00:00 2001 From: Travis Kemen Date: Fri, 9 May 2008 18:46:16 +0000 Subject: [PATCH] add bandwidthd SVN-Revision: 11099 --- utils/bandwidthd/Makefile | 51 +++++++++++++ .../patches/100-fix_config_file_location | 31 ++++++++ .../bandwidthd/patches/200-write_to_tmp_only | 76 +++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 utils/bandwidthd/Makefile create mode 100644 utils/bandwidthd/patches/100-fix_config_file_location create mode 100644 utils/bandwidthd/patches/200-write_to_tmp_only diff --git a/utils/bandwidthd/Makefile b/utils/bandwidthd/Makefile new file mode 100644 index 0000000000..4a9aac4481 --- /dev/null +++ b/utils/bandwidthd/Makefile @@ -0,0 +1,51 @@ +# +# Copyright (C) 2006-2008 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# $Id: Makefile 11018 2008-05-03 12:11:35Z nico $ + +include $(TOPDIR)/rules.mk + +PKG_NAME:=bandwidthd +PKG_VERSION:=2.0.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tgz +PKG_SOURCE_URL:=@SF/bandwidthd +PKG_MD5SUM:=aa79aad7bd489fd2cae1f7dc086ca8b6 + +include $(INCLUDE_DIR)/package.mk + +define Package/bandwidthd + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Bandwidthd + URL:=http://bandwidthd.sourceforge.net/ + DEPENDS:=+libpng +libgd +libpcap +endef + +define Package/bandwidthd/daemon + This package contains bandwidthd a bandwith tracking utility. +endef + +CONFIGURE_ARGS += \ + ac_cv_file__sw_lib=no \ + ac_cv_file__sw_include=no \ + ac_cv_file__usr_pkg_lib=no \ + ac_cv_file__usr_pkg_include=no \ + ac_cv_file__usr_local_pgsql_lib=no \ + ac_cv_file__usr_local_pgsql_include=no \ + +EXTRA_CFLAGS+=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include +EXTRA_LDFLAGS+=-L$(STAGING_DIR)/usr/lib -Wl,-rpath-link,$(STAGING_DIR)/usr/lib + +define Package/bandwidthd/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bandwidthd $(1)/usr/sbin/ + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/bandwidthd.conf $(1)/etc/ +endef + +$(eval $(call BuildPackage,bandwidthd)) diff --git a/utils/bandwidthd/patches/100-fix_config_file_location b/utils/bandwidthd/patches/100-fix_config_file_location new file mode 100644 index 0000000000..ae44cd2e47 --- /dev/null +++ b/utils/bandwidthd/patches/100-fix_config_file_location @@ -0,0 +1,31 @@ +--- bandwidthd-2.0.1/bandwidthd.c.orig 2008-05-09 10:06:37.000000000 -0500 ++++ bandwidthd-2.0.1/bandwidthd.c 2008-05-09 10:32:54.000000000 -0500 +@@ -255,22 +255,22 @@ + + openlog("bandwidthd", LOG_CONS, LOG_DAEMON); + +- if (stat("./etc/bandwidthd.conf", &StatBuf)) ++ if (stat("/etc/bandwidthd.conf", &StatBuf)) + { + chdir(INSTALL_DIR); +- if (stat("./etc/bandwidthd.conf", &StatBuf)) ++ if (stat("/etc/bandwidthd.conf", &StatBuf)) + { +- printf("Cannot find ./etc/bandwidthd.conf or %s/etc/bandwidthd.conf\n", INSTALL_DIR); +- syslog(LOG_ERR, "Cannot find ./etc/bandwidthd.conf or %s/etc/bandwidthd.conf", INSTALL_DIR); ++ printf("Cannot find /etc/bandwidthd.conf or %s/etc/bandwidthd.conf\n", INSTALL_DIR); ++ syslog(LOG_ERR, "Cannot find /etc/bandwidthd.conf or %s/etc/bandwidthd.conf", INSTALL_DIR); + exit(1); + } + } + +- bdconfig_in = fopen("./etc/bandwidthd.conf", "rt"); ++ bdconfig_in = fopen("/etc/bandwidthd.conf", "rt"); + if (!bdconfig_in) + { + syslog(LOG_ERR, "Cannot open bandwidthd.conf"); +- printf("Cannot open ./etc/bandwidthd.conf\n"); ++ printf("Cannot open /etc/bandwidthd.conf\n"); + exit(1); + } + bdconfig_parse(); diff --git a/utils/bandwidthd/patches/200-write_to_tmp_only b/utils/bandwidthd/patches/200-write_to_tmp_only new file mode 100644 index 0000000000..3b1a18fbeb --- /dev/null +++ b/utils/bandwidthd/patches/200-write_to_tmp_only @@ -0,0 +1,76 @@ +--- bandwidthd-2.0.1/graph.c.orig 2008-05-09 10:37:51.000000000 -0500 ++++ bandwidthd-2.0.1/graph.c 2008-05-09 10:37:55.000000000 -0500 +@@ -199,7 +199,7 @@ + int SubnetCounter; + int Counter, tCounter; + time_t WriteTime; +- char filename[] = "./htdocs/index2.html"; ++ char filename[] = "/tmp/bandwidthd/index2.html"; + char *PeriodDesc; + + FILE *file; +@@ -217,9 +217,9 @@ + + if (config.tag == '1') + { +- if ((file = fopen("./htdocs/index.html", "wt")) == NULL) ++ if ((file = fopen("/tmp/bandwidthd/index.html", "wt")) == NULL) + { +- syslog(LOG_ERR, "Failed to open ./htdocs/index.html"); ++ syslog(LOG_ERR, "Failed to open /tmp/bandwidthd/index.html"); + exit(1); + } + } +@@ -307,7 +307,7 @@ + for (SubnetCounter = 0; SubnetCounter < SubnetCount; SubnetCounter++) + { + HostIp2CharIp(SubnetTable[SubnetCounter].ip, Buffer1); +- sprintf(Buffer2, "./htdocs/Subnet-%c-%s.html", config.tag, Buffer1); ++ sprintf(Buffer2, "/tmp/bandwidthd/Subnet-%c-%s.html", config.tag, Buffer1); + file = fopen(Buffer2, "wt"); + fprintf(file, "\n"); + fprintf(file, "\nBandwidthd - Subnet %s\n", Buffer1); +@@ -411,12 +411,12 @@ + PrepareXAxis(im2, timestamp); + PrepareYAxis(im2, YMax); + +- sprintf(outputfilename, "./htdocs/%s-%c-S.png", CharIp, config.tag); ++ sprintf(outputfilename, "/tmp/bandwidthd/%s-%c-S.png", CharIp, config.tag); + OutputFile = fopen(outputfilename, "wb"); + gdImagePng(im, OutputFile); + fclose(OutputFile); + +- sprintf(outputfilename, "./htdocs/%s-%c-R.png", CharIp, config.tag); ++ sprintf(outputfilename, "/tmp/bandwidthd/%s-%c-R.png", CharIp, config.tag); + OutputFile = fopen(outputfilename, "wb"); + gdImagePng(im2, OutputFile); + fclose(OutputFile); +@@ -424,9 +424,9 @@ + else + { + // The graph isn't worth clutering up the web pages with +- sprintf(outputfilename, "./htdocs/%s-%c-R.png", CharIp, config.tag); ++ sprintf(outputfilename, "/tmp/bandwidthd/%s-%c-R.png", CharIp, config.tag); + unlink(outputfilename); +- sprintf(outputfilename, "./htdocs/%s-%c-S.png", CharIp, config.tag); ++ sprintf(outputfilename, "/tmp/bandwidthd/%s-%c-S.png", CharIp, config.tag); + unlink(outputfilename); + } + +--- bandwidthd-2.0.1/bandwidthd.c.orig 2008-05-09 10:06:37.000000000 -0500 ++++ bandwidthd-2.0.1/bandwidthd.c 2008-05-09 10:38:55.000000000 -0500 +@@ -333,10 +333,10 @@ + + if (config.graph) + { +- bd_CollectingData("htdocs/index.html"); +- bd_CollectingData("htdocs/index2.html"); +- bd_CollectingData("htdocs/index3.html"); +- bd_CollectingData("htdocs/index4.html"); ++ bd_CollectingData("/tmp/bandwidthd/index.html"); ++ bd_CollectingData("/tmp/bandwidthd/index2.html"); ++ bd_CollectingData("/tmp/bandwidthd/index3.html"); ++ bd_CollectingData("/tmp/bandwidthd/index4.html"); + } + + /* detach from console. */ -- 2.30.2