You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.6 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006-2011 OpenWrt.org
  3. START=50
  4. STOP=50
  5. USE_PROCD=1
  6. pppoe_triggers() {
  7. local cfg="$1"
  8. local enabled interface
  9. config_get_bool enabled "$cfg" enabled 1
  10. [ "$enabled" -gt 0 ] || return 0
  11. config_get interface "$cfg" interface
  12. procd_add_reload_interface_trigger $interface
  13. }
  14. pppoe_instance() {
  15. local cfg="$1"
  16. local enabled interface device ac_name service_names service_name maxsessionsperpeer localip firstremoteip maxsessions optionsfiles randomsession unit offset timeout mss sync OPTIONS
  17. config_get_bool enabled "$cfg" enabled 1
  18. [ "$enabled" -gt 0 ] || return 0
  19. config_get interface "$cfg" interface
  20. config_get ac_name "$cfg" ac_name
  21. config_get service_names "$cfg" service_name
  22. config_get maxsessionsperpeer "$cfg" maxsessionsperpeer
  23. config_get localip "$cfg" localip
  24. config_get firstremoteip "$cfg" firstremoteip
  25. config_get maxsessions "$cfg" maxsessions
  26. config_get optionsfile "$cfg" optionsfile
  27. config_get_bool randomsession "$cfg" randomsession 1
  28. config_get_bool unit "$cfg" unit 0
  29. config_get offset "$cfg" offset
  30. config_get timeout "$cfg" timeout
  31. config_get mss "$cfg" mss
  32. config_get_bool sync "$cfg" sync 0
  33. config_get_bool use_non_uci_config "$cfg" use_non_uci_config 0
  34. if [ "$use_non_uci_config" -gt 0 ]; then
  35. . /etc/default/pppoe-server
  36. else
  37. . /lib/functions/network.sh
  38. network_get_physdev device $interface || return 1
  39. [ -n "$ac_name" ] && append OPTIONS "-C $ac_name"
  40. for service_name in $service_names; do
  41. append OPTIONS "-S $service_name"
  42. done
  43. append OPTIONS "-I $device"
  44. [ -n "$maxsessionsperpeer" ] && append OPTIONS "-x $maxsessionsperpeer"
  45. [ -n "$localip" ] && append OPTIONS "-L $localip"
  46. [ -n "$firstremoteip" ] && append OPTIONS "-R $firstremoteip"
  47. [ -n "maxsessions" ] && append OPTIONS "-N $maxsessions"
  48. [ -n "optionsfile" ] && append OPTIONS "-O $optionsfile"
  49. [ "$randomsession" = "1" ] && append OPTIONS "-r"
  50. [ "$unit" = "1" ] && append OPTIONS "-u"
  51. [ -n "$offset" ] && append OPTIONS "-o $offset"
  52. [ -n "$timeout" ] && append OPTIONS "-T $timeout"
  53. [ -n "$mss" ] && append OPTIONS "-m $mss"
  54. [ "$sync" = "1" ] && append OPTIONS "-s"
  55. fi
  56. procd_open_instance
  57. procd_set_param command /usr/sbin/pppoe-server -F -k $OPTIONS
  58. procd_set_param respawn
  59. procd_set_param file /etc/ppp/options
  60. procd_append_param file /etc/ppp/pppoe-server-options
  61. procd_close_instance
  62. }
  63. start_service() {
  64. config_load pppoe
  65. config_foreach pppoe_instance pppoe_server
  66. }
  67. service_triggers() {
  68. procd_add_reload_trigger "pppoe"
  69. config_load pppoe
  70. config_foreach pppoe_triggers pppoe_server
  71. }