lantiq: use power leds defined in DTS
[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 local default
20 config_load system
21 config_get default led_adsl default
22 if [ "$default" != 1 ]; then
23         case "$DSL_INTERFACE_STATUS" in
24           "HANDSHAKE")  led_timer dsl 500 500;;
25           "TRAINING")   led_timer dsl 200 200;;
26           "UP")         led_on dsl;;
27           *)            led_off dsl
28         esac
29 fi
30
31 local interfaces=`ubus list network.interface.\* | cut -d"." -f3`
32 local ifc
33 for ifc in $interfaces; do
34
35         local up
36         json_load "$(ifstatus $ifc)"
37         json_get_var up up
38
39         local auto
40         config_get_bool auto "$ifc" auto 1
41
42         local proto
43         json_get_var proto proto
44
45         if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
46                 if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$auto" = 1 ]; then
47                         ( sleep 1; ifup "$ifc" ) &
48                 fi
49         else
50                 if [ "$proto" = "pppoa" ] && [ "$up" = 1 ] && [ "$auto" = 1 ]; then
51                         ( sleep 1; ifdown "$ifc" ) &
52                 else
53                         json_get_var autostart autostart
54                         if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$autostart" = 1 ]; then
55                                 ( sleep 1; ifdown "$ifc" ) &
56                         fi
57                 fi
58         fi
59 done
60
61