v-suspend-database 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. # info: suspend database
  3. # options: USER DATABASE
  4. # labels: panel
  5. #
  6. # example: v-suspend-database admin admin_wordpress_db
  7. #
  8. # The function for suspending a certain user database.
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Argument definition
  13. user=$1
  14. database=$2
  15. # Includes
  16. source $HESTIA/func/main.sh
  17. source $HESTIA/func/db.sh
  18. source $HESTIA/conf/hestia.conf
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '2' "$#" 'USER DATABASE'
  23. is_format_valid 'user' 'database'
  24. is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
  25. is_object_valid 'user' 'USER' "$user"
  26. is_object_unsuspended 'user' 'USER' "$user"
  27. is_object_valid 'db' 'DB' "$database"
  28. is_object_unsuspended 'db' 'DB' "$database"
  29. # Perform verification if read-only mode is enabled
  30. check_hestia_demo_mode
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Get database values
  35. get_database_values
  36. # Switching on db type
  37. case $TYPE in
  38. mysql) suspend_mysql_database ;;
  39. pgsql) suspend_pgsql_database ;;
  40. esac
  41. #----------------------------------------------------------#
  42. # Hestia #
  43. #----------------------------------------------------------#
  44. # Updating db value
  45. update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'yes'
  46. increase_user_value "$user" '$SUSPENDED_DB'
  47. # Logging
  48. log_event "$OK" "$ARGUMENTS"
  49. exit