diff options
author | Jean-Michel Lacroix <lacroix@lepine-lacroix.info> | 2017-01-01 12:44:56 -0500 |
---|---|---|
committer | Jean-Michel Lacroix <lacroix@lepine-lacroix.info> | 2017-01-01 12:44:56 -0500 |
commit | 5c9665a0706cd9de96a2e49f8ad3102a37acd36f (patch) | |
tree | bfeeaf12e059de2d1f270d47a15c91426e7b68e7 /utils/bandwidthd/files/bandwidthd-php.init | |
parent | a876e13fd614d81c6dd295e014d01738416ec9a5 (diff) |
bandwidthd: update to 2.0.1-34, sqlite support and SMTP tracking
Addition of sqlite storage
Tracking of SMTP traffic instead of P2P traffic
Based on NethServer bandwidthd implementation
Signed-off-by: Jean-Michel lacroix <lacroix@lepine-lacroix.info>
Diffstat (limited to 'utils/bandwidthd/files/bandwidthd-php.init')
-rwxr-xr-x | utils/bandwidthd/files/bandwidthd-php.init | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/utils/bandwidthd/files/bandwidthd-php.init b/utils/bandwidthd/files/bandwidthd-php.init new file mode 100755 index 000000000..b7b6434f0 --- /dev/null +++ b/utils/bandwidthd/files/bandwidthd-php.init @@ -0,0 +1,75 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2017 OpenWrt.org + +START=99 + +USE_PROCD=1 + +CONFIGNAME="bandwidthd-php" +CONFIGFILE="/var/etc/bandwidthd-php.conf" + +config_cb() { + local cfg_type="$1" + local cfg_name="$2" + case "$cfg_type" in + $CONFIGNAME) + append cfgs "$cfg_name" + ;; + esac +} + +export_number() { + local option="$1" + local section="$2" + local _loctmp + paramstr="" + config_get _loctmp "$section" "$option" + if [ -n "$_loctmp" ]; then + paramstr="${_loctmp}" + fi +} + +export_string() { + local option="$1" + local section="$2" + local _loctmp + paramstr="" + config_get _loctmp "$section" "$option" + if [ -n "$_loctmp" ]; then + paramstr="${_loctmp}" + fi +} + +service_triggers() +{ + procd_add_reload_trigger $CONFIGNAME +} + + +start_service() { + local conffile="<?php\n// auto-generated config file from /etc/config/${CONFIGNAME}\n" + rm -f $CONFIGFILE + touch $CONFIGFILE + + config_load $CONFIGNAME + for cfg in $cfgs; do + export_number dflt_width $cfg + conffile="${conffile}define(\"DFLT_WIDTH\", ${paramstr:-"900"});\n" + + export_number dflt_height $cfg + conffile="${conffile}define(\"DFLT_HEIGHT\", ${paramstr:-"256"});\n" + + export_string dflt_interval $cfg + conffile="${conffile}define(\"DFLT_INTERVAL\", ${paramstr:-"INT_DAILY"});\n\n"'$db_connect_string = "host=' + + export_string host $cfg + conffile="${conffile}${paramstr:-"127.0.0.1"} user=" + + export_string user $cfg + conffile="${conffile}${paramstr:-"postgres"} dbname=" + + export_string dbname $cfg + conffile="${conffile}${paramstr:-"bandwidthd"}"'"'"\n?>" + [ -n "$conffile" ] && echo -e "$conffile" >>$CONFIGFILE + done +} |