v-rebuild-databases 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # info: rebuild databases
  3. # options: USER
  4. #
  5. # The function for rebuilding of all databases of a single user.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. # Includes
  12. source $VESTA/conf/vesta.conf
  13. source $VESTA/func/main.sh
  14. source $VESTA/func/db.sh
  15. source $VESTA/func/rebuild.sh
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '1' "$#" 'USER'
  20. validate_format 'user'
  21. is_system_enabled "$DB_SYSTEM"
  22. is_object_valid 'user' 'USER' "$user"
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. # Starting rebuild loop
  27. for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do
  28. # Get database values
  29. get_database_values
  30. # Switching on db type
  31. case $TYPE in
  32. mysql) rebuild_mysql_database ;;
  33. pgsql) rebuild_pgsql_database ;;
  34. esac
  35. done
  36. #----------------------------------------------------------#
  37. # Vesta #
  38. #----------------------------------------------------------#
  39. # Logging
  40. log_event "$OK" "$EVENT"
  41. exit