br2684ctl: convert init script to procd, add hotplug/reload support
[openwrt/svn-archive/archive.git] / package / network / utils / linux-atm / files / br2684ctl
1 #!/bin/sh /etc/rc.common
2
3 START=50
4 USE_PROCD=1
5
6 start_daemon() {
7 local cfg="$1"
8
9 local atmdev
10 config_get atmdev "$cfg" atmdev 0
11
12 local unit
13 config_get unit "$cfg" unit 0
14
15 local vpi
16 config_get vpi "$cfg" vpi 8
17
18 local vci
19 config_get vci "$cfg" vci 35
20
21 local encaps
22 config_get encaps "$cfg" encaps
23
24 case "$encaps" in
25 1|vc) encaps=1;;
26 *) encaps=0;;
27 esac
28
29 local payload
30 config_get payload "$cfg" payload
31
32 case "$payload" in
33 0|routed) payload=0;;
34 *) payload=1;;
35 esac
36
37 local qos
38 config_get qos "$cfg" qos
39
40 local sendsize
41 config_get sendsize "$cfg" sendsize
42
43 found=
44 for device in /sys/class/atm/*; do
45 [ -d "$device" ] || break
46 [ "$(cat $device/atmindex)" = "$atmdev" ] || continue
47 found=1
48 break
49 done
50
51 [ -n "$found" ] || return
52
53 local circuit="$atmdev.$vpi.$vci"
54
55 procd_open_instance
56 procd_set_param command \
57 /usr/sbin/br2684ctl \
58 -c "$unit" -e "$encaps" -p "$payload" \
59 -a "$circuit" ${qos:+-q "$qos"} ${sendsize:+-s "$sendsize"}
60 procd_close_instance
61 }
62
63 service_running() {
64 . /lib/functions/network.sh
65
66 sleep 1
67 for path in /sys/class/net/nas*; do
68 dev="${path##*/}"
69 network_ready_device "$dev"
70 done
71 }
72
73 service_triggers() {
74 local script=$(readlink "$initscript")
75 local name=$(basename ${script:-$initscript})
76
77 procd_open_trigger
78 procd_add_raw_trigger hotplug.atm 2000 /etc/init.d/$name reload
79 procd_add_config_trigger "config.change" "$file" /etc/init.d/$name reload
80 procd_close_trigger
81 }
82
83 start_service() {
84 config_load network
85 config_foreach start_daemon atm-bridge
86 }