diff options
| author | John Crispin | 2024-09-21 15:53:24 +0000 |
|---|---|---|
| committer | John Crispin | 2024-10-02 13:41:33 +0000 |
| commit | 859bb4dd3fe88ffe6b461559a39e3cc1e0547892 (patch) | |
| tree | 9a47aa3a5a89c596f92e0c75639eb37bbf34c89b | |
| parent | 5071e842b99b1fe96f7364693eeb4850a4878e51 (diff) | |
| download | openwrt-859bb4dd3fe88ffe6b461559a39e3cc1e0547892.tar.gz | |
base-files: set root password if present inside board.json
Add code to set plain password or put the hash into /etc/shadow.
Signed-off-by: John Crispin <john@phrozen.org>
| -rw-r--r-- | package/base-files/files/etc/uci-defaults/50-root-passwd | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/package/base-files/files/etc/uci-defaults/50-root-passwd b/package/base-files/files/etc/uci-defaults/50-root-passwd new file mode 100644 index 0000000000..9eddf1559b --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/50-root-passwd @@ -0,0 +1,12 @@ +. /usr/share/libubox/jshn.sh + +json_init +json_load "$(cat /etc/board.json)" + +json_select credentials + json_get_vars root_password_hash root_password_hash + [ -z "$root_password_hash" ] || sed -i "s|^root:[^:]*|root:$root_password_hash|g" /etc/shadow + + json_get_vars root_password_plain root_password_plain + [ -z "$root_password_plain" ] || { (echo "$root_password_plain"; sleep 1; echo "$root_password_plain") | passwd root } +json_select .. |