diff options
author | Felix Fietkau <nbd@openwrt.org> | 2009-03-29 05:01:25 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2009-03-29 05:01:25 +0000 |
commit | c614ca2b92b1d2d2a5533855d7bed6ddff2145dd (patch) | |
tree | f7bf3f216d41f435eb535a1dcfcb523566af486a /package/wprobe/files | |
parent | 43eef5c7ea397bd78da7a525da72587c5eb73fa0 (diff) | |
download | upstream-c614ca2b92b1d2d2a5533855d7bed6ddff2145dd.tar.gz upstream-c614ca2b92b1d2d2a5533855d7bed6ddff2145dd.tar.bz2 upstream-c614ca2b92b1d2d2a5533855d7bed6ddff2145dd.zip |
wprobe: add init script for exporter
SVN-Revision: 15066
Diffstat (limited to 'package/wprobe/files')
-rwxr-xr-x | package/wprobe/files/wprobe.init | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/package/wprobe/files/wprobe.init b/package/wprobe/files/wprobe.init new file mode 100755 index 0000000000..3c62a03066 --- /dev/null +++ b/package/wprobe/files/wprobe.init @@ -0,0 +1,46 @@ +#!/bin/sh /etc/rc.common +START=90 + +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 -- "$@" +} + +stop_wprobe() { + local cfg="$1" + [ -f "/var/run/wprobe-$cfg.pid" ] && wprobe_ssd "$cfg" -K + rm -f "/var/run/wprobe-$cfg.pid" +} + +start_wprobe() { + local cfg="$1" + config_get ifname "$cfg" interface + 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 + } + wprobe_ssd "$cfg" -S "$proto" -i "$ifname" -c "$host" -p "${port:-4739}" +} + +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 start_wprobe wprobe +} |