2014-01-17 13:59:51 +00:00
|
|
|
#!/bin/sh
|
|
|
|
uci -q get dhcp.odhcpd && exit 0
|
|
|
|
touch /etc/config/dhcp
|
|
|
|
|
2017-09-01 11:22:11 +00:00
|
|
|
. /usr/share/libubox/jshn.sh
|
|
|
|
|
|
|
|
json_load "$(cat /etc/board.json)"
|
|
|
|
json_select network
|
|
|
|
json_select lan
|
|
|
|
json_get_vars protocol
|
|
|
|
json_select ..
|
|
|
|
json_select ..
|
|
|
|
|
|
|
|
case "$protocol" in
|
|
|
|
# only enable server mode on statically addressed lan ports
|
2018-09-12 01:21:19 +00:00
|
|
|
"static") [ -e /proc/sys/net/ipv6 ] && MODE=server || MODE=disabled ;;
|
2017-09-01 11:22:11 +00:00
|
|
|
*) MODE=disabled ;;
|
|
|
|
esac
|
|
|
|
|
2014-01-17 13:59:51 +00:00
|
|
|
uci batch <<EOF
|
|
|
|
set dhcp.odhcpd=odhcpd
|
|
|
|
set dhcp.odhcpd.maindhcp=0
|
|
|
|
set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
|
|
|
|
set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
|
2017-03-06 16:12:31 +00:00
|
|
|
set dhcp.odhcpd.loglevel=4
|
2017-09-01 11:22:11 +00:00
|
|
|
set dhcp.lan.dhcpv6=$MODE
|
|
|
|
set dhcp.lan.ra=$MODE
|
2019-06-29 19:07:12 +00:00
|
|
|
set dhcp.lan.ra_slaac=1
|
|
|
|
add_list dhcp.lan.ra_flags=managed-config
|
|
|
|
add_list dhcp.lan.ra_flags=other-config
|
2014-01-17 13:59:51 +00:00
|
|
|
commit dhcp
|
|
|
|
EOF
|