1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-10-18 05:18:14 +02:00

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>
This commit is contained in:
John Crispin 2024-09-21 17:53:24 +02:00
parent 5071e842b9
commit 859bb4dd3f

@ -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 ..