[packages] stun: fix init script (#9528)
[openwrt/svn-archive/archive.git] / net / stun / files / stund.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2009-2011 OpenWrt.org
3
4 START=70
5
6 start() {
7 local pri_ip sec_ip pri_port sec_port
8 parse_opts() {
9 local cfg="$1"
10 config_get pri_ip "$cfg" primaryip
11 config_get sec_ip "$cfg" secondaryip
12 config_get pri_port "$cfg" primaryport
13 config_get sec_port "$cfg" secondaryport
14 }
15
16 config_load "stund"
17 config_foreach parse_opts
18
19 start-stop-daemon -S -p /var/run/stund.pid -m -b \
20 -x /usr/sbin/stund -- \
21 ${pri_ip:+-h $pri_ip} ${sec_ip:+-a $sec_ip} \
22 ${pri_port:+-p $pri_port} ${sec_port:+-o $sec_port}
23 }
24
25 stop() {
26 service_kill stund /var/run/stund.pid
27 rm -f /var/run/stund.pid
28 }