lantiq: restore netdev trigger of dsl led on line up
[openwrt/staging/chunkeey.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 led_dsl_up() {
17 case "$(config_get led_dsl trigger)" in
18 "netdev")
19 led_set_attr $1 "trigger" "netdev"
20 led_set_attr $1 "device_name" "$(config_get led_dsl dev)"
21 led_set_attr $1 "mode" "$(config_get led_dsl mode)"
22 ;;
23 *)
24 led_on $1
25 ;;
26 esac
27 }
28
29 include /lib/network
30 scan_interfaces
31
32 config_load system
33 config_get led led_dsl sysfs
34 if [ -n "$led" ]; then
35 case "$DSL_INTERFACE_STATUS" in
36 "HANDSHAKE") led_timer $led 500 500;;
37 "TRAINING") led_timer $led 200 200;;
38 "UP") led_dsl_up $led;;
39 *) led_off $led
40 esac
41 fi
42
43 interfaces=`ubus list network.interface.\* | cut -d"." -f3`
44 for ifc in $interfaces; do
45
46 json_load "$(ifstatus $ifc)"
47
48 json_get_var proto proto
49 if [ "$proto" != "pppoa" ]; then
50 continue
51 fi
52
53 json_get_var up up
54 config_get_bool auto "$ifc" auto 1
55 if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
56 if [ "$up" != 1 ] && [ "$auto" = 1 ]; then
57 ( sleep 1; ifup "$ifc" ) &
58 fi
59 else
60 if [ "$up" = 1 ] && [ "$auto" = 1 ]; then
61 ( sleep 1; ifdown "$ifc" ) &
62 else
63 json_get_var autostart autostart
64 if [ "$up" != 1 ] && [ "$autostart" = 1 ]; then
65 ( sleep 1; ifdown "$ifc" ) &
66 fi
67 fi
68 fi
69 done
70
71