b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | . /usr/share/libubox/jshn.sh |
| 2 | |
| 3 | json_init |
| 4 | json_load "$(cat /etc/board.json)" |
| 5 | |
| 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 |
| 12 | |
| 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 |