Skip to content

Commit

Permalink
base-files: improve default root-passwd script
Browse files Browse the repository at this point in the history
The script was not exiting cleanly causing it to not be removed from the
uci-defaults folder.

Signed-off-by: John Crispin <john@phrozen.org>
  • Loading branch information
blogic committed Nov 13, 2024
1 parent 4c65359 commit b902284
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions package/base-files/files/etc/uci-defaults/50-root-passwd
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
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
if json_is_a credentials object; then
json_select credentials
json_get_vars root_password_hash root_password_hash
if [ -n "$root_password_hash" ]; then
sed -i "s|^root:[^:]*|root:$root_password_hash|g" /etc/shadow
fi

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 ..
json_get_vars root_password_plain root_password_plain
if [ -n "$root_password_plain" ]; then
(echo "$root_password_plain"; sleep 1; echo "$root_password_plain") | passwd root
fi
json_select ..
fi

0 comments on commit b902284

Please sign in to comment.