3c62a03066d00b923b4228083ca2c63bb96567a0
[openwrt.git] / package / wprobe / files / wprobe.init
1 #!/bin/sh /etc/rc.common
2 START=90
3
4 wprobe_ssd() {
5 local cfg="$1"; shift
6 local cmd="$1"; shift
7 start-stop-daemon "$cmd" -p "/var/run/wprobe-$cfg.pid" -b -x /sbin/wprobe-export -m -- "$@"
8 }
9
10 stop_wprobe() {
11 local cfg="$1"
12 [ -f "/var/run/wprobe-$cfg.pid" ] && wprobe_ssd "$cfg" -K
13 rm -f "/var/run/wprobe-$cfg.pid"
14 }
15
16 start_wprobe() {
17 local cfg="$1"
18 config_get ifname "$cfg" interface
19 config_get host "$cfg" host
20 config_get port "$cfg" port
21 config_get proto "$cfg" proto
22 case "$proto" in
23 sctp) proto="-s";;
24 tcp) proto="-t";;
25 udp) proto="-u";;
26 *) proto="-t";;
27 esac
28 [ -z "$ifname" -o -z "$host" ] && {
29 echo "wprobe-export: missing host or interface name in config $cfg"
30 return
31 }
32 wprobe_ssd "$cfg" -S "$proto" -i "$ifname" -c "$host" -p "${port:-4739}"
33 }
34
35 stop() {
36 for f in /var/run/wprobe-*.pid; do
37 CFG="${f%%.pid}"
38 CFG="${CFG##/var/run/wprobe-}"
39 stop_wprobe "$CFG"
40 done
41 }
42
43 start() {
44 config_load wprobe
45 config_foreach start_wprobe wprobe
46 }
This page took 0.041143 seconds and 3 git commands to generate.