v_change_db_password 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. # info: change database user password
  3. # options: user db_name db_password
  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. db_password=$3
  14. # Importing variables
  15. source $VESTA/conf/vars.conf
  16. source $V_CONF/vesta.conf
  17. source $V_FUNC/shared.func
  18. source $V_FUNC/db.func
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. # Checking arg number
  23. check_args '3' "$#" 'user db_name db_password'
  24. # Checking argument format
  25. format_validation 'user' 'database' 'db_password'
  26. # Checking db system is enabled
  27. is_system_enabled 'db'
  28. # Checking user
  29. is_user_valid
  30. # Checking user is active
  31. is_user_suspended
  32. # Checking db existance
  33. is_db_valid
  34. # Checking db is active
  35. is_db_suspended
  36. #----------------------------------------------------------#
  37. # Action #
  38. #----------------------------------------------------------#
  39. # Define database variables
  40. db_user=$(get_db_value '$USER')
  41. host=$(get_db_value '$HOST')
  42. type=$(get_db_value '$TYPE')
  43. # Switching on db type
  44. case $type in
  45. mysql) change_db_mysql_password ;;
  46. pgsql) change_db_pgsql_password ;;
  47. esac
  48. #----------------------------------------------------------#
  49. # Vesta #
  50. #----------------------------------------------------------#
  51. # Hiding password
  52. V_EVENT="$V_DATE $V_SCRIPT $user $database *****"
  53. # Logging
  54. log_event 'system' "$V_EVENT"
  55. exit