v_suspend_web_domain 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. # Importing variables
  16. source $VESTA/conf/vars.conf
  17. source $V_CONF/vesta.conf
  18. source $V_FUNC/shared.func
  19. source $V_FUNC/domain.func
  20. # Defining url
  21. url="${3-$V_SUSPEND_URL}"
  22. #----------------------------------------------------------#
  23. # Verifications #
  24. #----------------------------------------------------------#
  25. # Checking arg number
  26. check_args '2' "$#" 'user domain [suspend_url]'
  27. # Checking argument format
  28. format_validation 'user' 'domain' 'url'
  29. # Checking web system is enabled
  30. is_system_enabled 'web'
  31. # Checking user
  32. is_user_valid
  33. # Checking domain exist
  34. is_web_domain_valid
  35. # Checking domain is not suspened
  36. is_domain_suspended 'web'
  37. #----------------------------------------------------------#
  38. # Action #
  39. #----------------------------------------------------------#
  40. # Parsing domain values
  41. get_web_domain_values
  42. tpl_file="$V_WEBTPL/apache_$TPL.tpl"
  43. conf="$V_HOME/$user/conf/httpd.conf"
  44. SUSPEND='yes'
  45. # Preparing domain values for the template substitution
  46. upd_web_domain_values
  47. # Recreating vhost
  48. del_web_config
  49. add_web_config
  50. # Check ssl
  51. if [ "$SSL" = 'yes' ]; then
  52. tpl_file="$V_WEBTPL/apache_$TPL.stpl"
  53. conf="$V_HOME/$user/conf/shttpd.conf"
  54. del_web_config
  55. add_web_config
  56. fi
  57. # Checking nginx
  58. if [ ! -z "$NGINX" ]; then
  59. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
  60. conf="$V_HOME/$user/conf/nginx.conf"
  61. del_web_config
  62. add_web_config
  63. if [ "$SSL" = 'yes' ]; then
  64. proxy_string="rewrite ^(.*)\$ http://$url;"
  65. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
  66. conf="$V_HOME/$user/conf/snginx.conf"
  67. del_web_config
  68. add_web_config
  69. fi
  70. fi
  71. #----------------------------------------------------------#
  72. # Vesta #
  73. #----------------------------------------------------------#
  74. # Adding suspend in config
  75. update_web_domain_value '$SUSPEND' 'yes'
  76. # Adding task to the vesta pipe
  77. restart_schedule 'web'
  78. # Logging
  79. log_event 'system' "$V_EVENT"
  80. exit