[PATCH 02/11] base-files: uci-defaults: allow setting default credentials and ssh keys

John Crispin john at phrozen.org
Mon Sep 23 10:18:16 PDT 2024


Introduce new uci-default functions:
     - ucidef_set_root_password [password hash/cleartext]
     - ucidef_set_ssh_authorized_key [ssh key]

Signed-off-by: John Crispin <john at phrozen.org>
---
 .../base-files/files/lib/functions/uci-defaults.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index ba7288c2c6..bcc78220cc 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -677,6 +677,20 @@ ucidef_set_country() {
 	json_select ..
 }
 
+ucidef_set_root_password() {
+	local passwd="$1"
+	json_select_object credentials
+		json_add_string root_password "$passwd"
+	json_select ..
+}
+
+ucidef_set_ssh_authorized_key() {
+	local ssh_key="$1"
+	json_select_object credentials
+		json_add_string ssh_authorized_key "$ssh_key"
+	json_select ..
+}
+
 ucidef_set_ntpserver() {
 	local server
 
-- 
2.34.1




More information about the openwrt-devel mailing list