build: add option to use preinit IP as LAN IP
[openwrt/staging/dangole.git] / package / base-files / Makefile
index 914f0598ff9c181952f20f769e64d2b1121b6ae2..8732f82fb9815ea67dc548bd897836249ea893c9 100644 (file)
@@ -89,6 +89,19 @@ define ImageConfigOptions
        echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
        echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
        echo 'pi_preinit_no_failsafe="$(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE)"' >>$(1)/lib/preinit/00_preinit.conf
+ifeq ($(CONFIG_TARGET_DEFAULT_LAN_IP_FROM_PREINIT),y)
+       mkdir -p $(1)/etc/board.d
+       echo '. /lib/functions/uci-defaults.sh' >$(1)/etc/board.d/99-lan-ip
+       echo 'logger -t 99-lan-ip "setting custom default LAN IP"' >>$(1)/etc/board.d/99-lan-ip
+       echo 'board_config_update' >>$(1)/etc/board.d/99-lan-ip
+       echo 'json_select network' >>$(1)/etc/board.d/99-lan-ip
+       echo 'json_select lan' >>$(1)/etc/board.d/99-lan-ip
+       echo 'json_add_string ipaddr $(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/etc/board.d/99-lan-ip
+       echo 'json_add_string netmask $(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/etc/board.d/99-lan-ip
+       echo 'json_select ..' >>$(1)/etc/board.d/99-lan-ip
+       echo 'json_select ..' >>$(1)/etc/board.d/99-lan-ip
+       echo 'board_config_flush' >>$(1)/etc/board.d/99-lan-ip
+endif
 endef
 
 define Build/Prepare