v_change_db_password 1.6 KB

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