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 ..
|
|
|
|
|
2021-02-14 22:39:24 +00:00
|
|
|
ODHCPDONLY=0
|
|
|
|
V4MODE=disabled
|
|
|
|
V6MODE=disabled
|
|
|
|
|
|
|
|
[ -e /usr/sbin/dnsmasq ] || ODHCPDONLY=1
|
|
|
|
|
2017-09-01 11:22:11 +00:00
|
|
|
case "$protocol" in
|
|
|
|
# only enable server mode on statically addressed lan ports
|
2021-02-14 22:39:24 +00:00
|
|
|
"static")
|
|
|
|
V4MODE=server
|
|
|
|
[ -e /proc/sys/net/ipv6 ] && V6MODE=server
|
|
|
|
;;
|
2017-09-01 11:22:11 +00:00
|
|
|
esac
|
|
|
|
|
2021-02-14 22:39:24 +00:00
|
|
|
uci get dhcp.lan 1>/dev/null 2>/dev/null || {
|
|
|
|
uci batch <<EOF
|
|
|
|
set dhcp.lan=dhcp
|
|
|
|
set dhcp.lan.interface='lan'
|
|
|
|
set dhcp.lan.start='100'
|
|
|
|
set dhcp.lan.limit='150'
|
|
|
|
set dhcp.lan.leasetime='12h'
|
|
|
|
set dhcp.lan.domain='lan'
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2014-01-17 13:59:51 +00:00
|
|
|
uci batch <<EOF
|
|
|
|
set dhcp.odhcpd=odhcpd
|
2021-02-14 22:39:24 +00:00
|
|
|
set dhcp.odhcpd.maindhcp=$ODHCPDONLY
|
2014-01-17 13:59:51 +00:00
|
|
|
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
|
2021-02-14 22:39:24 +00:00
|
|
|
set dhcp.lan.dhcpv4=$V4MODE
|
|
|
|
set dhcp.lan.dhcpv6=$V6MODE
|
|
|
|
set dhcp.lan.ra=$V6MODE
|
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
|