From patchwork Mon Sep 23 17:18:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1988677 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=b6Z8qWND; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XC8t01Z5Cz1xsg for ; Tue, 24 Sep 2024 03:21:28 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DgDsy7Rq7GC1UAHmexcfOv4lGFvQ0Icr/VfX7V5pms0=; b=b6Z8qWNDpBCfNx Lf8pFzrRzb42GIwgo4qtE7KvzjywKQWVDNFu91OlOMf3ts08hYxiQ11fZLaIMkx7/7gDbpaBuzmW6 X90Q4MR9ieEzNtcuWHrwI8Eq+MYJWLOy8HiTe09ADnj5J6g3iEbSA//PK7Ysh8QhZZ/gMghyoAXZ9 wOEgrHlRWyekuwere10RKC6UinhkWXFtnKqI5igtwDqnAqbQtxpLZ24hz9mozFp4rVFVvOtxC0VLz hEd9U8jZz16Jeo7QKAZBdUBMlFQwAB6+UXrvFXfu4s0LfLcjrM+IpRKRrOhPC2+RLc/JDDOIQ15ds zoeHe+jyLHcW9TTEj0JA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1ssmhv-000000006vG-2gxA; Mon, 23 Sep 2024 17:18:43 +0000 Received: from nbd.name ([46.4.11.11]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1ssmhp-000000006rv-1ujq for openwrt-devel@lists.openwrt.org; Mon, 23 Sep 2024 17:18:40 +0000 Received: from [2a04:4540:1404:e800:43a1:93c8:f672:7397] (helo=bertha10..) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ssmhm-00HS5P-0q for openwrt-devel@lists.openwrt.org; Mon, 23 Sep 2024 19:18:34 +0200 From: John Crispin To: openwrt-devel@lists.openwrt.org Subject: [PATCH 07/11] uboot-envtools: add a board.d script to load defaults from the environment Date: Mon, 23 Sep 2024 19:18:21 +0200 Message-Id: <20240923171825.148902-8-john@phrozen.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240923171825.148902-1-john@phrozen.org> References: <20240923171825.148902-1-john@phrozen.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240923_101837_525608_CF08EFAE X-CRM114-Status: UNSURE ( 9.70 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This allows loading default wifi credentials, passwords and ssh keys on firstboot. Signed-off-by: John Crispin --- package/boot/uboot-envtools/Makefile | 2 ++ package/boot/uboot-envtools/files/fw_defaults | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) cre [...] Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [46.4.11.11 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [46.4.11.11 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [46.4.11.11 listed in bl.score.senderscore.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This allows loading default wifi credentials, passwords and ssh keys on firstboot. Signed-off-by: John Crispin --- package/boot/uboot-envtools/Makefile | 2 ++ package/boot/uboot-envtools/files/fw_defaults | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 package/boot/uboot-envtools/files/fw_defaults 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..5ef27f6cad --- /dev/null +++ b/package/boot/uboot-envtools/files/fw_defaults @@ -0,0 +1,16 @@ +. /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 ] && ucidef_set_root_password "$(cat /var/run/uboot-env/owrt_root_password)" +[ -f /var/run/uboot-env/owrt_timezone ] && ucidef_set_timezone "$(cat /var/run/uboot-env/owrt_timezone)" + +board_config_flush + +exit 0