Remove broken patch which was causing the path to be incremented as well as the file...
authorTravis Kemen <thepeople@openwrt.org>
Fri, 16 May 2008 16:34:09 +0000 (16:34 +0000)
committerTravis Kemen <thepeople@openwrt.org>
Fri, 16 May 2008 16:34:09 +0000 (16:34 +0000)
SVN-Revision: 11149

utils/bandwidthd/Makefile
utils/bandwidthd/files/bandwidthd.config [new file with mode: 0644]
utils/bandwidthd/files/bandwidthd.init [new file with mode: 0644]
utils/bandwidthd/patches/200-write_to_tmp_only [deleted file]

index 4a9aac4481d293aaf0411a34672761ffcf5d3912..62c1963ec156fe5f9b51b7a9d3fec89724d39f71 100644 (file)
@@ -44,8 +44,12 @@ 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/
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/bandwidthd.config $(1)/etc/config/bandwidthd
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/bandwidthd.init $(1)/etc/init.d/bandwidthd
+       $(INSTALL_DIR) $(1)/www
+       $(INSTALL_DATA) $(PKG_BUILD_DIR)/htdocs/legend.gif $(1)/www/
 endef
 
 $(eval $(call BuildPackage,bandwidthd))
diff --git a/utils/bandwidthd/files/bandwidthd.config b/utils/bandwidthd/files/bandwidthd.config
new file mode 100644 (file)
index 0000000..dee7f93
--- /dev/null
@@ -0,0 +1,11 @@
+config bandwidthd
+       option interface        br-lan
+       option subnets          "192.168.0.0/16 10.0.0.0/8 172.16.0.0/12"
+       option skip_intervals   0
+       option graph_cutoff     1024
+       option promiscuous      true
+       option output_cdf       false
+       option recover_cdf      false
+       option filter           ip
+       option graph            true
+       option meta_refresh     150
diff --git a/utils/bandwidthd/files/bandwidthd.init b/utils/bandwidthd/files/bandwidthd.init
new file mode 100644 (file)
index 0000000..7ba8807
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org
+START=99
+
+config_cb() {
+       local cfg_type="$1"
+       local cfg_name="$2"
+
+       case "$cfg_type" in
+               bandwidthd)
+                       append cfgs "$cfg_name"
+               ;;
+       esac
+}
+
+start() {
+       [ -d /tmp/bandwidthd ] || mkdir -p /tmp/bandwidthd && cp /www/ledgend.gif /tmp/bandwidthd/
+       [ -e /htdocs ] || ln -s /tmp/bandwidthd /htdocs
+       [ -e /www/bandwidthd ] || ln -s /tmp/bandwidthd /www/bandwidthd
+       rm -f /tmp/bandwidthd.conf
+       touch /tmp/bandwidthd.conf
+       [ -e /etc/bandwidthd.conf ] || ln -s /tmp/bandwidthd.conf /etc/bandwidthd.conf
+       
+       
+       config_load bandwidthd
+       for cfg in $cfgs; do
+               config_get interface $cfg interface
+               config_get subnets $cfg interface
+               config_get skip_intervals $cfg skip_intervals
+               config_get graph_cutoff $cfg graph_cutoff
+               config_get promiscuous $cfg promiscuous
+               config_get output_cdf $cfg output_cdf
+               config_get recover_cdf $cfg recover_cdf
+               config_get filter $cfg filter
+               config_get graph $cfg graph
+               config_get meta_refresh $cfg meta_refresh
+                       for subnet in $subnets
+                               echo "subnet $subnet">> /tmp/bandwidthd.conf
+                       done
+               cat >> /tmp/bandwidthd.conf <<EOF
+${interface:+ dev "$interface"}
+${skip_intervals:+ skip_intervals $skip_intervals}
+${graph_cutoff:+ graph_cutoff $graph_cutoff}
+${promiscuous:+ promiscuous $promiscuous}
+${output_cdf:+ output_cdf $output_cdf}
+${recover_cdf:+ recover_cdf $recover_cdf}
+${filter:+ filter $filter}
+${graph:+ graph $graph}
+${meta_refresh:+ meta_refresh $meta_refresh}
+EOF
+       done
+       bandwidthd
+}
+
+stop() {
+       killall bandwidthd
+}
diff --git a/utils/bandwidthd/patches/200-write_to_tmp_only b/utils/bandwidthd/patches/200-write_to_tmp_only
deleted file mode 100644 (file)
index 3b1a18f..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
---- 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, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
-               fprintf(file, "<HTML>\n<HEAD><TITLE>Bandwidthd - Subnet %s</TITLE>\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. */