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.

53 lines
1.1 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2012 OpenWrt.org
  3. START=91
  4. SERVICE_SIG="KILL"
  5. SERVICE_PID_FILE="/var/run/dhcrelay4.pid"
  6. SERVICE_USE_PID=1
  7. start() {
  8. . /lib/functions/network.sh
  9. config_load dhcrelay
  10. local args=""
  11. local enabled
  12. config_get_bool enabled ipv4 enabled 0
  13. [ "$enabled" -eq 0 ] && return 0
  14. # listen interfaces
  15. local interfaces
  16. local ifname
  17. config_get interfaces ipv4 interfaces
  18. for net in $interfaces; do
  19. if network_get_device ifname "$net"; then
  20. append args "-i $ifname"
  21. fi
  22. done
  23. # link selection sub-option (RFC3527)
  24. local link_selection
  25. config_get link_selection ipv4 link_selection
  26. if network_get_device ifname "$link_selection"; then
  27. append args "-U $ifname"
  28. fi
  29. # relay mode
  30. local relay_mode
  31. config_get relay_mode ipv4 relay_mode
  32. [ -n "$relay_mode" ] && append args "-m $relay_mode"
  33. # dhcp server address
  34. local server
  35. config_get server ipv4 dhcpserver
  36. [ -n "$server" ] || return 0
  37. append args "$server"
  38. service_start /usr/sbin/dhcrelay -4 -q \
  39. -pf $SERVICE_PID_FILE $args
  40. }
  41. stop() {
  42. service_stop /usr/sbin/dhcrelay
  43. }