pppoe-relay.init 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006-2011 OpenWrt.org
  3. START=50
  4. USE_PROCD=1
  5. pppoe_triggers() {
  6. local cfg="$1"
  7. local interface server_interfaces client_interfaces both_interfaces
  8. config_get server_interfaces "$cfg" server_interface
  9. config_get client_interfaces "$cfg" client_interface
  10. config_get both_interfaces "$cfg" both_interfaces
  11. for interface in $server_interfaces; do
  12. append interfaces "$interface" "|"
  13. done
  14. for interface in $client_interfaces; do
  15. append interfaces "$interface" "|"
  16. done
  17. for interface in $both_interfaces; do
  18. append interfaces "$interface" "|"
  19. done
  20. }
  21. pppoe_relay_instance() {
  22. local cfg="$1"
  23. local interface server_interfaces client_interfaces both_interfaces maxsessions timeout OPTIONS
  24. config_get server_interfaces "$cfg" server_interface
  25. config_get client_interfaces "$cfg" client_interface
  26. config_get both_interfaces "$cfg" both_interfaces
  27. config_get maxsessions "$cfg" maxsesssions
  28. config_get timeout "$cfg" timeout
  29. config_get_bool use_non_uci_config "$cfg" use_non_uci_config 0
  30. if [ "$use_non_uci_config" -gt 0 ]; then
  31. . /etc/default/pppoe-relay
  32. else
  33. [ -z "${server_interfaces}${client_interfaces}${both_interfaces}" ] && return 1
  34. for interface in $server_interfaces; do
  35. append OPTIONS "-S $interface"
  36. done
  37. for interface in $client_interfaces; do
  38. append OPTIONS "-C $interface"
  39. done
  40. for interface in $both_interfaces; do
  41. append OPTIONS "-B $interface"
  42. done
  43. [ -n "$maxsesssions" ] && append OPTIONS "-n $maxsesssions"
  44. [ -n "$timeout" ] && append OPTIONS "-i $timeout"
  45. fi
  46. procd_open_instance
  47. procd_set_param command /usr/sbin/pppoe-relay -F
  48. procd_append_param command $OPTIONS
  49. procd_close_instance
  50. }
  51. start_service() {
  52. local use_non_uci_config
  53. config_load pppoe
  54. config_foreach pppoe_relay_instance pppoe_relay
  55. }
  56. reload_triggers() {
  57. local interfaces
  58. config_load pppoe
  59. config_foreach pppoe_triggers pppoe_relay
  60. procd_add_reload_trigger "pppoe"
  61. procd_add_interface_trigger "$interfaces"
  62. }