v-suspend-web-domain 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 defenition
  12. user=$1
  13. domain=$(idn -t --quiet -u "$2" )
  14. domain_idn=$(idn -t --quiet -a "$domain")
  15. restart=$3
  16. # Includes
  17. source $VESTA/conf/vesta.conf
  18. source $VESTA/func/main.sh
  19. source $VESTA/func/domain.sh
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. check_args '2' "$#" 'user domain [restart]'
  24. validate_format 'user' 'domain'
  25. is_system_enabled "$WEB_SYSTEM"
  26. is_object_valid 'user' 'USER' "$user"
  27. is_object_valid 'web' 'DOMAIN' "$domain"
  28. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Parsing domain values
  33. get_domain_values 'web'
  34. tpl_file="$WEBTPL/apache_$TPL.tpl"
  35. conf="$HOMEDIR/$user/conf/web/httpd.conf"
  36. SUSPENDED='yes'
  37. # Preparing domain values for the template substitution
  38. upd_web_domain_values
  39. # Recreating vhost
  40. del_web_config
  41. add_web_config
  42. # Check ssl
  43. if [ "$SSL" = 'yes' ]; then
  44. tpl_file="$WEBTPL/apache_$TPL.stpl"
  45. conf="$HOMEDIR/$user/conf/web/shttpd.conf"
  46. del_web_config
  47. add_web_config
  48. fi
  49. # Checking nginx
  50. if [ ! -z "$NGINX" ]; then
  51. tpl_file="$WEBTPL/nginx_$NGINX.tpl"
  52. conf="$HOMEDIR/$user/conf/web/nginx.conf"
  53. del_web_config
  54. add_web_config
  55. if [ "$SSL" = 'yes' ]; then
  56. tpl_file="$WEBTPL/nginx_$NGINX.stpl"
  57. conf="$HOMEDIR/$user/conf/web/snginx.conf"
  58. del_web_config
  59. add_web_config
  60. fi
  61. fi
  62. #----------------------------------------------------------#
  63. # Vesta #
  64. #----------------------------------------------------------#
  65. # Update config
  66. update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
  67. increase_user_value "$user" '$SUSPENDED_WEB'
  68. # Restart web server
  69. if [ "$restart" != 'no' ]; then
  70. $BIN/v-restart-web "$EVENT"
  71. fi
  72. # Logging
  73. log_event "$OK" "$EVENT"
  74. exit