dsl_notify.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. [ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
  10. . /usr/share/libubox/jshn.sh
  11. . /lib/functions.sh
  12. . /lib/functions/leds.sh
  13. include /lib/network
  14. scan_interfaces
  15. config_load system
  16. config_get led led_dsl sysfs
  17. if [ -n "$led" ]; then
  18. case "$DSL_INTERFACE_STATUS" in
  19. "HANDSHAKE") led_timer $led 500 500;;
  20. "TRAINING") led_timer $led 200 200;;
  21. "UP") led_on $led;;
  22. *) led_off $led
  23. esac
  24. fi
  25. interfaces=`ubus list network.interface.\* | cut -d"." -f3`
  26. for ifc in $interfaces; do
  27. json_load "$(ifstatus $ifc)"
  28. json_get_var up up
  29. config_get_bool auto "$ifc" auto 1
  30. json_get_var proto proto
  31. if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
  32. if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$auto" = 1 ]; then
  33. ( sleep 1; ifup "$ifc" ) &
  34. fi
  35. else
  36. if [ "$proto" = "pppoa" ] && [ "$up" = 1 ] && [ "$auto" = 1 ]; then
  37. ( sleep 1; ifdown "$ifc" ) &
  38. else
  39. json_get_var autostart autostart
  40. if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$autostart" = 1 ]; then
  41. ( sleep 1; ifdown "$ifc" ) &
  42. fi
  43. fi
  44. fi
  45. done