dsl_notify.sh 1.4 KB

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