1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-04 19:03:09 +02:00
openwrt-xburst/package/wprobe/files/wprobe.init
nbd 26c5a541b5 wprobe: add init script for exporter
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@15066 3c298f89-4303-0410-b956-a3cf2f4a3e73
2009-03-29 05:01:25 +00:00

47 lines
972 B
Bash
Executable File

#!/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
}