kernel: move mv88e6xxx fix to generic backports
[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 ODHCPDONLY=0
15 V4MODE=disabled
16 V6MODE=disabled
17
18 [ -e /usr/sbin/dnsmasq ] || ODHCPDONLY=1
19
20 case "$protocol" in
21 # only enable server mode on statically addressed lan ports
22 "static")
23 V4MODE=server
24 [ -e /proc/sys/net/ipv6 ] && V6MODE=server
25 ;;
26 esac
27
28 uci get dhcp.lan 1>/dev/null 2>/dev/null || {
29 uci batch <<EOF
30 set dhcp.lan=dhcp
31 set dhcp.lan.interface='lan'
32 set dhcp.lan.start='100'
33 set dhcp.lan.limit='150'
34 set dhcp.lan.leasetime='12h'
35 set dhcp.lan.domain='lan'
36 EOF
37 }
38
39 uci batch <<EOF
40 set dhcp.odhcpd=odhcpd
41 set dhcp.odhcpd.maindhcp=$ODHCPDONLY
42 set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
43 set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
44 set dhcp.odhcpd.loglevel=4
45 set dhcp.lan.dhcpv4=$V4MODE
46 set dhcp.lan.dhcpv6=$V6MODE
47 set dhcp.lan.ra=$V6MODE
48 set dhcp.lan.ra_slaac=1
49 add_list dhcp.lan.ra_flags=managed-config
50 add_list dhcp.lan.ra_flags=other-config
51 commit dhcp
52 EOF