merge madwifi and wprobe into 8.09
[openwrt/svn-archive/archive.git] / package / wprobe / files / wprobe.init
index 3c62a03066d00b923b4228083ca2c63bb96567a0..26d5c3d31263784912836ec1bb15b8a72b46b305 100755 (executable)
@@ -1,19 +1,34 @@
 #!/bin/sh /etc/rc.common
 START=90
+EXPORTER=/usr/sbin/wprobe-ipfix
+UTIL=/sbin/wprobe-util
 
 wprobe_ssd() {
-       local cfg="$1"; shift
        local cmd="$1"; shift
-       start-stop-daemon "$cmd" -p "/var/run/wprobe-$cfg.pid" -b -x /sbin/wprobe-export -m -- "$@"
+       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 cfg="$1"
-       [ -f "/var/run/wprobe-$cfg.pid" ] && wprobe_ssd "$cfg" -K
-       rm -f "/var/run/wprobe-$cfg.pid"
+       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_wprobe() {
+start_ipfix() {
        local cfg="$1"
        config_get ifname "$cfg" interface
        config_get host "$cfg" host
@@ -29,7 +44,17 @@ start_wprobe() {
                echo "wprobe-export: missing host or interface name in config $cfg"
                return
        }
-       wprobe_ssd "$cfg" -S "$proto" -i "$ifname" -c "$host" -p "${port:-4739}"
+       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() {
@@ -42,5 +67,6 @@ stop() {
 
 start() {
        config_load wprobe
-       config_foreach start_wprobe wprobe
+       config_foreach config_wprobe interface
+       config_foreach start_export export
 }