[openwrt/openwrt] uboot-envtools: add a board.d script to load defaults from the environment

LEDE Commits lede-commits at lists.infradead.org
Wed Oct 2 06:48:12 PDT 2024


blogic pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/b89b19b85436803513dc89681b17918c8fd9521f

commit b89b19b85436803513dc89681b17918c8fd9521f
Author: John Crispin <john at phrozen.org>
AuthorDate: Tue Sep 17 17:30:46 2024 +0200

    uboot-envtools: add a board.d script to load defaults from the environment
    
    This allows loading default wifi credentials, passwords and ssh keys on
    firstboot.
    
    Signed-off-by: John Crispin <john at phrozen.org>
---
 package/boot/uboot-envtools/Makefile          |  2 ++
 package/boot/uboot-envtools/files/fw_defaults | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile
index 875afad554..61939be6de 100644
--- a/package/boot/uboot-envtools/Makefile
+++ b/package/boot/uboot-envtools/Makefile
@@ -72,6 +72,8 @@ define Package/uboot-envtools/install
 	$(INSTALL_BIN) ./files/fw_printsys $(1)/usr/sbin
 	$(INSTALL_BIN) ./files/fw_setsys $(1)/usr/sbin
 	$(INSTALL_BIN) ./files/fw_loadenv $(1)/usr/sbin
+	$(INSTALL_DIR) $(1)/etc/board.d
+	$(INSTALL_DATA) ./files/fw_defaults $(1)/etc/board.d/05_fw_defaults
 	$(INSTALL_DIR) $(1)/lib
 	$(INSTALL_DATA) ./files/uboot-envtools.sh $(1)/lib
 	$(INSTALL_DIR) $(1)/etc/uci-defaults
diff --git a/package/boot/uboot-envtools/files/fw_defaults b/package/boot/uboot-envtools/files/fw_defaults
new file mode 100644
index 0000000000..42558aaa88
--- /dev/null
+++ b/package/boot/uboot-envtools/files/fw_defaults
@@ -0,0 +1,17 @@
+. /lib/functions/uci-defaults.sh
+
+fw_loadenv
+
+board_config_update
+
+[ -f /var/run/uboot-env/owrt_ssid -a -f /var/run/uboot-env/owrt_wifi_key ] &&
+	ucidef_set_wireless all "$(cat /var/run/uboot-env/owrt_ssid)" sae-mixed "$(cat /var/run/uboot-env/owrt_wifi_key)"
+[ -f /var/run/uboot-env/owrt_country ] && ucidef_set_country "$(cat /var/run/uboot-env/owrt_country)"
+[ -f /var/run/uboot-env/owrt_ssh_auth_key ] && ucidef_set_ssh_authorized_key "$(cat /var/run/uboot-env/owrt_ssh_auth_key)"
+[ -f /var/run/uboot-env/owrt_root_password_plain ] && ucidef_set_root_password_plain "$(cat /var/run/uboot-env/owrt_root_password_plain)"
+[ -f /var/run/uboot-env/owrt_root_password_hash ] && ucidef_set_root_password_hash "$(cat /var/run/uboot-env/owrt_root_password_hash)"
+[ -f /var/run/uboot-env/owrt_timezone ] && ucidef_set_timezone "$(cat /var/run/uboot-env/owrt_timezone)"
+
+board_config_flush
+
+exit 0




More information about the lede-commits mailing list