v_change_database_password 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. # info: change database password
  3. # options: user database dbpass
  4. #
  5. # The function for changing database user password to a database. It uses the
  6. # full name of database as argument.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument defenition
  11. user=$1
  12. database=$2
  13. dbpass=$3
  14. # Includes
  15. source $VESTA/conf/vesta.conf
  16. source $VESTA/func/main.sh
  17. source $VESTA/func/db.sh
  18. # Hiding password
  19. A3='******'
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. check_args '3' "$#" 'user database dbpass'
  24. validate_format 'user' 'database' 'dbpass'
  25. is_system_enabled "$DB_SYSTEM"
  26. is_object_valid 'user' 'USER' "$user"
  27. is_object_unsuspended 'user' 'USER' "$user"
  28. is_object_valid 'db' 'DB' "$database"
  29. is_object_unsuspended 'db' 'DB' "$database"
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Get database values
  34. get_database_values
  35. case $TYPE in
  36. mysql) change_mysql_password ;;
  37. pgsql) change_pgsql_password ;;
  38. esac
  39. #----------------------------------------------------------#
  40. # Vesta #
  41. #----------------------------------------------------------#
  42. # Update config value
  43. update_object_value 'db' 'DB' "$database" '$MD5' "$md5"
  44. # Logging
  45. log_event "$OK" "$EVENT"
  46. exit