v_suspend_web_domain 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. # info: suspening web domain (with ssl)
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. domain=$(idn -t --quiet -u "$2" )
  9. domain_idn=$(idn -t --quiet -a "$domain")
  10. # Importing variables
  11. source $VESTA/conf/vars.conf
  12. source $V_FUNC/shared_func.sh
  13. source $V_FUNC/domain_func.sh
  14. # Defining url
  15. url="${3-$V_SUSPEND_URL}"
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. # Checking arg number
  20. check_args '2' "$#" 'user domain [suspend_url]'
  21. # Checking argument format
  22. format_validation 'user' 'domain' 'url'
  23. # Checking web system is enabled
  24. is_system_enabled 'web'
  25. # Checking user
  26. is_user_valid
  27. # Checking domain exist
  28. is_web_domain_valid
  29. # Checking domain is not suspened
  30. is_domain_suspended 'web'
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Get template name
  35. tpl_name=$(get_web_domain_value '$TPL')
  36. tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
  37. # Defining config
  38. conf="$V_HOME/$user/conf/httpd.conf"
  39. # Defining search phrase
  40. search_phrase='DocumentRoot '
  41. # Defining replace string
  42. str_repl=" Redirect / http://$url"
  43. # Suspending vhost
  44. change_web_config
  45. # Check ssl vhost
  46. cert=$(get_web_domain_value '$SSL_CERT')
  47. if [ ! -z "$cert" ]; then
  48. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  49. conf="$V_HOME/$user/conf/shttpd.conf"
  50. str_repl=" Redirect / http://$url"
  51. change_web_config
  52. fi
  53. # Check nginx vhost
  54. nginx=$(get_web_domain_value '$NGINX')
  55. if [ ! -z "$nginx" ]; then
  56. tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
  57. conf="$V_HOME/$user/conf/nginx.conf"
  58. search_phrase='proxy_pass'
  59. str_repl=" rewrite ^(.*)\$ http://$url;"
  60. change_web_config
  61. fi
  62. if [ ! -z "$nginx" ] && [ ! -z "$cert" ]; then
  63. tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
  64. conf="$V_HOME/$user/conf/snginx.conf"
  65. search_phrase='proxy_pass'
  66. str_repl=" rewrite ^(.*)\$ http://$url;"
  67. change_web_config
  68. fi
  69. #----------------------------------------------------------#
  70. # Vesta #
  71. #----------------------------------------------------------#
  72. # Adding suspend in config
  73. update_web_domain_value '$SUSPEND' 'yes'
  74. # Adding task to the vesta pipe
  75. restart_schedule 'web'
  76. # Logging
  77. log_event 'system' "$V_EVENT"
  78. exit $OK