aboutsummaryrefslogtreecommitdiffstats
path: root/package/wprobe/files/wprobe.init
diff options
context:
space:
mode:
authorblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-05 10:12:53 +0000
committerblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-10-05 10:12:53 +0000
commit5c105d9f3fd086aff195d3849dcf847d6b0bd927 (patch)
tree1229a11f725bfa58aa7c57a76898553bb5f6654a /package/wprobe/files/wprobe.init
downloadopenwrt-5c105d9f3fd086aff195d3849dcf847d6b0bd927.tar.gz
openwrt-5c105d9f3fd086aff195d3849dcf847d6b0bd927.zip
branch Attitude Adjustment
git-svn-id: svn://svn.openwrt.org/openwrt/branches/attitude_adjustment@33625 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/wprobe/files/wprobe.init')
-rwxr-xr-xpackage/wprobe/files/wprobe.init72
1 files changed, 72 insertions, 0 deletions
diff --git a/package/wprobe/files/wprobe.init b/package/wprobe/files/wprobe.init
new file mode 100755
index 000000000..b35246d42
--- /dev/null
+++ b/package/wprobe/files/wprobe.init
@@ -0,0 +1,72 @@
+#!/bin/sh /etc/rc.common
+START=90
+EXPORTER=/sbin/wprobe-export
+UTIL=/sbin/wprobe-util
+
+wprobe_ssd() {
+ local cmd="$1"; shift
+ local type="$1"; shift
+ local app="$1"; shift
+ start-stop-daemon "$cmd" -p "/var/run/wprobe-$type.pid" -b ${app:+-x "$app"} -m -- "$@"
+}
+
+stop_wprobe() {
+ local type="$1"
+ [ -f "/var/run/wprobe-$type.pid" ] && wprobe_ssd -K "$type"
+ rm -f "/var/run/wprobe-$type.pid"
+}
+
+config_wprobe() {
+ config_get ifname "$cfg" ifname
+ config_get interval "$cfg" interval
+ [ -n "$interval" ] || interval=100
+ $UTIL "$ifname" -i "$interval" 2>/dev/null >/dev/null
+}
+
+start_proxy() {
+ config_get port "$cfg" port
+ wprobe_ssd -S proxy "$UTIL" -P -p "${port:-17990}"
+}
+
+start_ipfix() {
+ local cfg="$1"
+ config_get ifname "$cfg" ifname
+ config_get host "$cfg" host
+ config_get port "$cfg" port
+ config_get proto "$cfg" proto
+ case "$proto" in
+ sctp) proto="-s";;
+ tcp) proto="-t";;
+ udp) proto="-u";;
+ *) proto="-t";;
+ esac
+ [ -z "$ifname" -o -z "$host" ] && {
+ echo "wprobe-export: missing host or interface name in config $cfg"
+ return
+ }
+ config_wprobe "$cfg"
+ wprobe_ssd -S "export-$cfg" "$EXPORTER" "$proto" -i "$ifname" -c "$host" -p "${port:-4739}"
+}
+
+start_export() {
+ local cfg="$1"
+ config_get export_type "$cfg" type
+ case "$export_type" in
+ ipfix) [ -x "$EXPORTER" ] && start_ipfix "$cfg";;
+ wprobe) start_proxy "$cfg";;
+ esac
+}
+
+stop() {
+ for f in /var/run/wprobe-*.pid; do
+ CFG="${f%%.pid}"
+ CFG="${CFG##/var/run/wprobe-}"
+ stop_wprobe "$CFG"
+ done
+}
+
+start() {
+ config_load wprobe
+ config_foreach config_wprobe interface
+ config_foreach start_export export
+}