odhcpd.defaults 653 B

1234567891011121314151617181920212223242526272829
  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") [ -e /proc/sys/net/ipv6 ] && MODE=server || MODE=disabled ;;
  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.odhcpd.loglevel=4
  22. set dhcp.lan.dhcpv6=$MODE
  23. set dhcp.lan.ra=$MODE
  24. commit dhcp
  25. EOF