50-root-passwd 510 B

123456789101112131415161718
  1. . /usr/share/libubox/jshn.sh
  2. json_init
  3. json_load "$(cat /etc/board.json)"
  4. if json_is_a credentials object; then
  5. json_select credentials
  6. json_get_vars root_password_hash root_password_hash
  7. if [ -n "$root_password_hash" ]; then
  8. sed -i "s|^root:[^:]*|root:$root_password_hash|g" /etc/shadow
  9. fi
  10. json_get_vars root_password_plain root_password_plain
  11. if [ -n "$root_password_plain" ]; then
  12. (echo "$root_password_plain"; sleep 1; echo "$root_password_plain") | passwd root
  13. fi
  14. json_select ..
  15. fi