aboutsummaryrefslogtreecommitdiff
path: root/net/darkstat/files
diff options
context:
space:
mode:
authorJean-Michel Lacroix <lacroix@lepine-lacroix.info>2016-07-07 09:43:48 -0400
committerJean-Michel Lacroix <lacroix@lepine-lacroix.info>2016-07-11 09:06:14 -0400
commite32b8b2c3442e3b4ee5facec8c5bc56376834abb (patch)
treeb75064418983c01ef063237613a4f2a6f68e8e96 /net/darkstat/files
parenta6368066b3c89c2dbd327e174c3f204f1132cd98 (diff)
darkstat: Network bandwidth monitor - version 3.0.719
Signed-off-by: Jean-Michel Lacroix <lacroix@lepine-lacroix.info> From the oldpackages. Updated to version 3.0.719, new config file to add more options Rewritten init file to take in account the new config file and removing a bug when stopping the daemon. Corrected license information in Makefile Signed-off-by: Jean-Michel Lacroix <lacroix@lepine-lacroix.info>
Diffstat (limited to 'net/darkstat/files')
-rw-r--r--net/darkstat/files/darkstat.config20
-rwxr-xr-xnet/darkstat/files/darkstat.init97
2 files changed, 117 insertions, 0 deletions
diff --git a/net/darkstat/files/darkstat.config b/net/darkstat/files/darkstat.config
new file mode 100644
index 000000000..ba7c1c2f6
--- /dev/null
+++ b/net/darkstat/files/darkstat.config
@@ -0,0 +1,20 @@
+config darkstat
+ option interface 'lan'
+ option syslog false
+ option verbose true
+ option no_daemon false
+ option no_promisc false
+ option no_dns false
+ option no_macs false
+ option no_lastseen false
+# option httpaddr '0.0.0.0'
+# option httpport '667'
+# option network_filter 'not (src net 192.168.1 and dst net 192.168.1)'
+# option network_netmask '192.168.1.0/255.255.255.0'
+ option local_only false
+# option hosts_max '1000'
+# option hosts_keep '500'
+# option ports_max '60'
+# option ports_keep '30'
+# option highest_port '65534'
+
diff --git a/net/darkstat/files/darkstat.init b/net/darkstat/files/darkstat.init
new file mode 100755
index 000000000..27d063ea4
--- /dev/null
+++ b/net/darkstat/files/darkstat.init
@@ -0,0 +1,97 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007-2016 OpenWrt.org
+
+START=60
+APP=darkstat
+RUN_D=/var/empty
+PID_F=$RUN_D/darkstat.pid
+
+SYSLOG=""
+VERBOSE=""
+NODAEMON=""
+NOPROMISC=""
+NODNS=""
+NOMACS=""
+NOLASTSEEN=""
+LOCAL=""
+paramstr=""
+
+export_bool () {
+ local option="$1"
+ local section="$2"
+ local _keystr="$3"
+ local _loctmp
+ paramstr=""
+ config_get_bool _loctmp "$section" "$option"
+ if [ -n "$_loctmp" ]; then
+ if [ 1 -eq "$_loctmp" ]; then
+ paramstr="${_keystr} "
+ fi
+ fi
+}
+
+start() {
+ mkdir -p $RUN_D
+ . /lib/functions/network.sh
+ config_load darkstat
+ config_foreach start_darkstat darkstat
+}
+
+start_darkstat() {
+ local cfg="$1"
+ config_get interface $cfg interface
+ export_bool syslog $cfg "--syslog"
+ SYSLOG=$paramstr
+ export_bool verbose $cfg "--verbose"
+ VERBOSE=$paramstr
+ export_bool no_daemon $cfg "--no-daemon"
+ NODAEMON=$paramstr
+ export_bool no_promisc $cfg "--no-promisc"
+ NOPROMISC=$paramstr
+ export_bool no_dns $cfg "--no-dns"
+ NODNS=$paramstr
+ export_bool no_macs $cfg "--no-macs"
+ NOMACS=$paramstr
+ export_bool no_lastseen $cfg "--no-lastseen"
+ NOLASTSEEN=$paramstr
+ config_get httpaddr $cfg httpaddr
+ config_get httpport $cfg httpport
+ config_get network_filter $cfg network_filter
+ config_get network_netmask $cfg network_netmask
+ export_bool local_only $cfg "--local-only"
+ LOCAL=$paramstr
+ config_get hosts_max $cfg hosts_max
+ config_get hosts_keep $cfg hosts_keep
+ config_get ports_max $cfg ports_max
+ config_get ports_keep $cfg ports_keep
+ config_get highest_port $cfg highest_port
+
+
+ network_get_device ifname "$interface" && {
+ /usr/sbin/$APP -i "$ifname" \
+ ${SYSLOG} \
+ ${VERBOSE} \
+ ${NODAEMON} \
+ ${NOPROMISC} \
+ ${NODNS} \
+ ${NOMACS} \
+ ${NOLASTSEEN} \
+ ${httpaddr:+-b "$httpaddr"} \
+ ${httpport:+-p "$httpport"} \
+ ${network_filter:+-f "$network_filter"} \
+ ${network_netmask:+-l "$network_netmask"} \
+ ${LOCAL} \
+ ${hosts_max:+--hosts-max "$hosts_max"} \
+ ${hosts_keep:+--hosts-keep "$hosts_keep"} \
+ ${ports_max:+--ports-max "$ports_max"} \
+ ${ports_keep:+--ports-keep "$ports_keep"} \
+ ${highest_port:+--highest-port "$highest_port"} \
+ --chroot $RUN_D \
+ --pidfile $PID_F
+ }
+}
+
+stop() {
+ start-stop-daemon -K -n $APP -p $PID_F -s TERM
+ rm -f $PID_F
+}