11ada923618abb0b6ea72b7efaf3aaf838aced6d
[openwrt/openwrt.git] / target / linux / lantiq / base-files / sbin / dsl_notify.sh
1 #!/bin/sh
2 #
3 # This script is called by dsl_cpe_control whenever there is a DSL event,
4 # we only actually care about the DSL_INTERFACE_STATUS events as these
5 # tell us the line has either come up or gone down.
6 #
7 # The rest of the code is basically the same at the atm hotplug code
8 #
9
10 [ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
11
12 . /usr/share/libubox/jshn.sh
13 . /lib/functions.sh
14 . /lib/functions/leds.sh
15
16 include /lib/network
17 scan_interfaces
18
19 config_load system
20 config_get led led_dsl sysfs
21 if [ -n "$led" ]; then
22 case "$DSL_INTERFACE_STATUS" in
23 "HANDSHAKE") led_timer $led 500 500;;
24 "TRAINING") led_timer $led 200 200;;
25 "UP") led_on $led;;
26 *) led_off $led
27 esac
28 fi
29
30 interfaces=`ubus list network.interface.\* | cut -d"." -f3`
31 for ifc in $interfaces; do
32
33 json_load "$(ifstatus $ifc)"
34
35 json_get_var proto proto
36 if [ "$proto" != "pppoa" ]; then
37 continue
38 fi
39
40 json_get_var up up
41 config_get_bool auto "$ifc" auto 1
42 if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
43 if [ "$up" != 1 ] && [ "$auto" = 1 ]; then
44 ( sleep 1; ifup "$ifc" ) &
45 fi
46 else
47 if [ "$up" = 1 ] && [ "$auto" = 1 ]; then
48 ( sleep 1; ifdown "$ifc" ) &
49 else
50 json_get_var autostart autostart
51 if [ "$up" != 1 ] && [ "$autostart" = 1 ]; then
52 ( sleep 1; ifdown "$ifc" ) &
53 fi
54 fi
55 fi
56 done
57
58