From: Travis Kemen Date: Fri, 20 Jun 2008 17:06:20 +0000 (+0000) Subject: Fix init script for bandwidthd. Thanks lubek X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=commitdiff_plain;h=3dc10ed90276ac64dd2c82728cc2a32955f177ec;ds=sidebyside Fix init script for bandwidthd. Thanks lubek SVN-Revision: 11547 --- diff --git a/utils/bandwidthd/files/bandwidthd.config b/utils/bandwidthd/files/bandwidthd.config index dee7f936b9..4bb18cf92d 100644 --- a/utils/bandwidthd/files/bandwidthd.config +++ b/utils/bandwidthd/files/bandwidthd.config @@ -1,5 +1,5 @@ config bandwidthd - option interface br-lan + option dev 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 diff --git a/utils/bandwidthd/files/bandwidthd.init b/utils/bandwidthd/files/bandwidthd.init index 10659712a0..2d53ac3c68 100644 --- a/utils/bandwidthd/files/bandwidthd.init +++ b/utils/bandwidthd/files/bandwidthd.init @@ -13,7 +13,45 @@ config_cb() { esac } +export_bool() { + local option="$1" + local section="$2" + local _loctmp + config_get_bool _loctmp "$section" "$option" + if [ -n "$_loctmp" ]; then + conffile="${conffile}$option " + if [ 1 -eq "$_loctmp" ]; then + conffile="${conffile}true" + else + conffile="${conffile}false" + fi + conffile="${conffile}\n" + fi +} + +export_number() { + local option="$1" + local section="$2" + local _loctmp + config_get _loctmp "$section" "$option" + if [ -n "$_loctmp" ]; then + conffile="${conffile}$option ${_loctmp}\n" + fi +} + +export_string() { + local option="$1" + local section="$2" + local _loctmp + config_get _loctmp "$section" "$option" + if [ -n "$_loctmp" ]; then + conffile="${conffile}$option \"${_loctmp}\"\n" + fi +} + start() { + local subnet conffile + [ -d /tmp/bandwidthd ] || mkdir -p /tmp/bandwidthd && cp /www/legend.gif /tmp/bandwidthd/ [ -e /htdocs ] || ln -s /tmp/bandwidthd /htdocs [ -e /www/bandwidthd ] || ln -s /tmp/bandwidthd /www/bandwidthd @@ -24,30 +62,21 @@ start() { 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 + config_get subnets $cfg subnets for subnet in $subnets; do - echo "subnet $subnet">> /tmp/bandwidthd.conf + conffile="${conffile}subnet ${subnet}\n" done - cat >> /tmp/bandwidthd.conf <>/tmp/bandwidthd.conf + unset conffile done cd / bandwidthd