1
0

pppoe-server.init 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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
  8. config_get interface "$cfg" interface
  9. }
  10. pppoe_instance() {
  11. local cfg="$1"
  12. local interface ac_name service_names service_name maxsessionsperpeer localip firstremoteip maxsessions optionsfiles randomsession unit offset timeout mss sync OPTIONS
  13. config_get interface "$cfg" interface
  14. config_get ac_name "$cfg" ac_name
  15. config_get service_names "$cfg" service_name
  16. config_get maxsessionsperpeer "$cfg" maxsessionsperpeer
  17. config_get localip "$cfg" localip
  18. config_get firstremoteip "$cfg" firstremoteip
  19. config_get maxsessions "$cfg" maxsessions
  20. config_get optionsfile "$cfg" optionsfile
  21. config_get_bool randomsession "$cfg" randomsession 1
  22. config_get_bool unit "$cfg" unit 0
  23. config_get offset "$cfg" offset
  24. config_get timeout "$cfg" timeout
  25. config_get mss "$cfg" mss
  26. config_get_bool sync "$cfg" sync 0
  27. config_get use_non_uci_config "$cfg" use_non_uci_config 0
  28. if [ "$use_non_uci_config" -gt 0 ]; then
  29. . /etc/default/pppoe-server
  30. else
  31. [ -z "$interface" ] && return 1
  32. [ -n "$ac_name" ] && append OPTIONS "-C $ac_name"
  33. for service_name in $service_names; do
  34. append OPTIONS "-S $service_name"
  35. done
  36. append OPTIONS "-I $interface"
  37. [ -n "$maxsessionsperpeer" ] && append OPTIONS "-x $maxsessionsperpeer"
  38. [ -n "$localip" ] && append OPTIONS "-L $localip"
  39. [ -n "$firstremoteip" ] && append OPTIONS "-R $firstremoteip"
  40. [ -n "maxsessions" ] && append OPTIONS "-N $maxsessions"
  41. [ -n "optionsfile" ] && append OPTIONS "-O $optionsfile"
  42. [ "$randomsession" = "1" ] && append OPTIONS "-r"
  43. [ "$unit" = "1" ] && append OPTIONS "-u"
  44. [ -n "$offset" ] && append OPTIONS "-o $offset"
  45. [ -n "$timeout" ] && append OPTIONS "-T $timeout"
  46. [ -n "$mss" ] && append OPTIONS "-m $mss"
  47. [ "$sync" = "1" ] && append OPTIONS "-s"
  48. fi
  49. procd_open_instance
  50. procd_set_param command /usr/sbin/pppoe-server -F
  51. procd_append_param command -k $OPTIONS
  52. procd_set_param file /etc/ppp/options
  53. procd_append_param file /etc/ppp/pppoe-server-options
  54. procd_close_instance
  55. }
  56. start_service() {
  57. config_load pppoe
  58. config_foreach pppoe_instance pppoe_server
  59. }
  60. service_triggers() {
  61. local interface
  62. config_load pppoe
  63. config_foreach pppoe_triggers pppoe_server
  64. procd_add_reload_trigger "pppoe"
  65. procd_add_interface_trigger "$interface"
  66. }