v-suspend-web-domain 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # info: suspend web domain
  3. # options: USER DOMAIN
  4. #
  5. # The function for suspending the site's operation. After blocking it all
  6. # visitors will be redirected to a web page explaining the reason of suspend.
  7. # By blocking the site the content of all its directories remains untouched.
  8. #----------------------------------------------------------#
  9. # Variable&Function #
  10. #----------------------------------------------------------#
  11. # Argument definition
  12. user=$1
  13. domain=$2
  14. restart=$3
  15. # Includes
  16. source $VESTA/func/main.sh
  17. source $VESTA/func/domain.sh
  18. source $VESTA/func/ip.sh
  19. source $VESTA/conf/vesta.conf
  20. # Additional argument formatting
  21. format_domain
  22. format_domain_idn
  23. #----------------------------------------------------------#
  24. # Verifications #
  25. #----------------------------------------------------------#
  26. check_args '2' "$#" 'USER DOMAIN [RESTART]'
  27. is_format_valid 'user' 'domain'
  28. is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
  29. is_object_valid 'user' 'USER' "$user"
  30. is_object_valid 'web' 'DOMAIN' "$domain"
  31. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. # Parsing domain values
  36. get_domain_values 'web'
  37. SUSPENDED='yes'
  38. local_ip=$(get_real_ip $IP)
  39. # Preparing domain values for the template substitution
  40. prepare_web_domain_values
  41. # Rebuilding vhost
  42. del_web_config "$WEB_SYSTEM" "$TPL.tpl"
  43. add_web_config "$WEB_SYSTEM" "$TPL.tpl"
  44. if [ "$SSL" = 'yes' ]; then
  45. del_web_config "$WEB_SYSTEM" "$TPL.stpl"
  46. add_web_config "$WEB_SYSTEM" "$TPL.stpl"
  47. fi
  48. # Rebuilding proxy configuration
  49. if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
  50. del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
  51. add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
  52. if [ "$SSL" = 'yes' ]; then
  53. del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
  54. add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
  55. fi
  56. fi
  57. #----------------------------------------------------------#
  58. # Vesta #
  59. #----------------------------------------------------------#
  60. # Updating config
  61. update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
  62. increase_user_value "$user" '$SUSPENDED_WEB'
  63. # Restarting web server
  64. $BIN/v-restart-web $restart
  65. check_result $? "Web restart failed" >/dev/null
  66. $BIN/v-restart-proxy $restart
  67. check_result $? "Proxy restart failed" >/dev/null
  68. # Logging
  69. log_event "$OK" "$ARGUMENTS"
  70. exit