v_suspend_web_domain 2.4 KB

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