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