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.lede-project.org./?a=commitdiff_plain;h=252de4d7b2b5edb2a3c0816441ec9b61107be55f;p=openwrt%2Fsvn-archive%2Fpackages.git 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 dee7f936b..4bb18cf92 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 10659712a..2d53ac3c6 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