Skip to content

Commit e39f5d4

Browse files
committed
base-files: improve default root-passwd script
The script was not exiting cleanly causing it to not be removed from the uci-defaults folder. Signed-off-by: John Crispin <[email protected]>
1 parent d83ae23 commit e39f5d4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

package/base-files/files/etc/uci-defaults/50-root-passwd

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
json_init
44
json_load "$(cat /etc/board.json)"
55

6-
json_select credentials
7-
json_get_vars root_password_hash root_password_hash
8-
[ -z "$root_password_hash" ] || sed -i "s|^root:[^:]*|root:$root_password_hash|g" /etc/shadow
6+
if json_is_a credentials object; then
7+
json_select credentials
8+
json_get_vars root_password_hash root_password_hash
9+
if [ -n "$root_password_hash" ]; then
10+
sed -i "s|^root:[^:]*|root:$root_password_hash|g" /etc/shadow
11+
fi
912

10-
json_get_vars root_password_plain root_password_plain
11-
[ -z "$root_password_plain" ] || { (echo "$root_password_plain"; sleep 1; echo "$root_password_plain") | passwd root }
12-
json_select ..
13+
json_get_vars root_password_plain root_password_plain
14+
if [ -n "$root_password_plain" ]; then
15+
(echo "$root_password_plain"; sleep 1; echo "$root_password_plain") | passwd root
16+
fi
17+
json_select ..
18+
fi

0 commit comments

Comments
 (0)