03-user-password 677 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # Licence : GPL v3
  3. # Author: Laurent HUBERT
  4. #
  5. # Changes the default user's password (id=1000)
  6. #
  7. # Default user should have id 1000:
  8. the_user=$(id -u 1000 -n)
  9. cat <<EOF
  10. ##################################
  11. # Changing $the_user password #
  12. ##################################
  13. EOF
  14. status=1
  15. while [ 0 -ne "$status" ]
  16. do
  17. passwd $the_user
  18. status=$?
  19. if [ 0 -ne "$status" ]
  20. then
  21. echo "Error changing $the_user password"
  22. echo "Please try again"
  23. else
  24. cat <<EOF
  25. **********************************
  26. * $the_user password : changed *
  27. **********************************
  28. EOF
  29. exit 0
  30. fi
  31. done
  32. echo "An error occurred changing $the_user password"
  33. exit $status