[packages] parprouted: use network.sh to find devices
[openwrt/svn-archive/archive.git] / net / parprouted / files / parprouted.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2012 OpenWrt.org
3
4 START=50
5
6 section_enabled() {
7 local enabled
8 config_get_bool enabled "$1" 'enabled' 0
9 [ $enabled -gt 0 ]
10 }
11
12 append_interface() {
13 local name="$1"
14 local device
15 network_get_device device "$name"
16 append args "${device:-$name}"
17 }
18
19 start_instance() {
20 local section="$1"
21 local permanent
22 local interfaces
23 local args=""
24
25 section_enabled "$section" || return 1
26
27 config_get_bool permanent "$section" 'permanent' 0
28 [ $permanent -eq 0 ] || append args "-p"
29
30 config_list_foreach "$section" 'interfaces' append_interface
31
32 service_start /usr/sbin/parprouted $args
33 }
34
35 start() {
36 . /lib/network/functions.sh
37
38 config_load 'parprouted'
39 config_foreach start_instance 'parprouted'
40 }
41
42 stop() {
43 service_stop /usr/sbin/parprouted
44 }