v_change_db_password 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_FUNC/shared_func.sh
  13. source $V_FUNC/db_func.sh
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking arg number
  18. check_args '3' "$#" 'user db_name db_password'
  19. # Checking argument format
  20. format_validation 'user' 'database' 'db_password'
  21. # Checking db system is enabled
  22. is_system_enabled 'db'
  23. # Checking user
  24. is_user_valid
  25. # Checking user is active
  26. is_user_suspended
  27. # Checking db existance
  28. is_db_valid
  29. # Checking db is active
  30. is_db_suspended
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Define database variables
  35. db_user=$(get_db_value '$USER')
  36. host=$(get_db_value '$HOST')
  37. type=$(get_db_value '$TYPE')
  38. # Switching on db type
  39. case $type in
  40. mysql) change_db_mysql_password ;;
  41. pgsql) change_db_pgsql_password ;;
  42. esac
  43. #----------------------------------------------------------#
  44. # Vesta #
  45. #----------------------------------------------------------#
  46. # Hiding password
  47. V_EVENT="$(date +%m-%d-%y" "%H:%m:%S) $V_SCRIPT $user $database *****"
  48. # Logging
  49. log_event 'system' "$V_EVENT"
  50. exit $OK