03-user-password 662 B

123456789101112131415161718192021222324252627282930
  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. echo "> $the_user password : changed <"
  25. exit 0
  26. fi
  27. done
  28. echo "### An error occurred changing $the_user password ###"
  29. exit $status