SetPassword 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # This file is part of the 'dragora-installer'.
  2. #
  3. # Purpose: Set super-user (root) password.
  4. # Make sure to have /dev available for passwd(1)
  5. if ! mountpoint -q /media/dragora-root/dev
  6. then
  7. mount --bind /dev /media/dragora-root/dev
  8. fi
  9. while test "$(grep -m 1 "^root:" /media/dragora-root/etc/shadow | cut -f 2 -d :)" = x
  10. do
  11. _status=0
  12. dialog --colors \
  13. --backtitle "\\ZbSystem administrator password" \
  14. --title "PASSWORD NOT DETECTED" \
  15. --ok-button "Continue" --msgbox \
  16. "No password has been detected for the system administrator\\n\
  17. (root) account.\\n\\nIt is important to set it in order to \
  18. have access to the entire system. Please do it now!" 10 62 || _status=$?
  19. if test $_status -eq 0
  20. then
  21. echo ""
  22. chroot /media/dragora-root /usr/bin/passwd root
  23. echo ""
  24. echo " To continue, press [Enter]..."
  25. IFS= read -r REPLY < /dev/tty || exit 2;
  26. unset -v REPLY
  27. continue;
  28. elif test $_status -eq 255
  29. then
  30. dialog \
  31. --title "System administrator password" \
  32. --defaultno --yesno \
  33. "\\nAre you sure you want to leave this without a password?\\n\
  34. You will not have full access to the system." 8 59 || continue;
  35. fi
  36. break;
  37. done
  38. unset -v _status
  39. # Refresh shadow files
  40. chroot /media/dragora-root /usr/sbin/shadowconfig off > /dev/null 2>&1 || true
  41. chroot /media/dragora-root /usr/sbin/shadowconfig on > /dev/null 2>&1 || true
  42. dialog --clear