odhcpd.defaults 580 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. uci -q get dhcp.odhcpd && exit 0
  3. touch /etc/config/dhcp
  4. . /usr/share/libubox/jshn.sh
  5. json_load "$(cat /etc/board.json)"
  6. json_select network
  7. json_select lan
  8. json_get_vars protocol
  9. json_select ..
  10. json_select ..
  11. case "$protocol" in
  12. # only enable server mode on statically addressed lan ports
  13. "static") MODE=server ;;
  14. *) MODE=disabled ;;
  15. esac
  16. uci batch <<EOF
  17. set dhcp.odhcpd=odhcpd
  18. set dhcp.odhcpd.maindhcp=0
  19. set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
  20. set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
  21. set dhcp.lan.dhcpv6=$MODE
  22. set dhcp.lan.ra=$MODE
  23. commit dhcp
  24. EOF