v_unsuspend_web_domain 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/bash
  2. # info: unsuspening 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. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking arg number
  18. check_args '2' "$#" 'user domain'
  19. # Checking argument format
  20. format_validation 'user' 'domain'
  21. # Checking web system is enabled
  22. is_system_enabled 'web'
  23. # Checking user
  24. is_user_valid
  25. # Checking domain exist
  26. is_web_domain_valid
  27. # Check domain is suspened
  28. is_domain_unsuspended 'web'
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Get template name
  33. tpl_name=$(get_web_domain_value '$TPL')
  34. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  35. # Defining config
  36. conf="$V_HOME/$user/conf/httpd.conf"
  37. # Defining search phrase
  38. search_phrase='Redirect / '
  39. # Defining replace string
  40. str_repl=" DocumentRoot $V_HOME/$user/web/$domain/public_html"
  41. # Unsuspending vhost
  42. change_web_config
  43. # Check ssl vhost
  44. cert=$(get_web_domain_value '$SSL_CERT')
  45. if [ ! -z "$cert" ]; then
  46. # Defining teplate name and ssl documentroot option
  47. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  48. tpl_option=$(get_web_domain_value '$SSL_HOME')
  49. # Defining config
  50. conf="$V_HOME/$user/conf/shttpd.conf"
  51. # Switching on option
  52. case $tpl_option in
  53. single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
  54. *) docroot="$V_HOME/$user/web/$domain/public_html" ;;
  55. esac
  56. # Defining replace string
  57. str_repl=" DocumentRoot $docroot"
  58. # Unsuspending vhost
  59. change_web_config
  60. fi
  61. # Check nginx vhost
  62. nginx=$(get_web_domain_value '$NGINX')
  63. if [ ! -z "$nginx" ]; then
  64. ip=$(get_web_domain_value '$IP')
  65. web_port=$(get_config_value '$WEB_PORT')
  66. tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
  67. conf="$V_HOME/$user/conf/nginx.conf"
  68. search_phrase='rewrite ^(.*)$'
  69. str_repl=" proxy_pass http://$ip:$web_port;"
  70. change_web_config
  71. fi
  72. if [ ! -z "$nginx" ] && [ ! -z "$cert" ]; then
  73. web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
  74. tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
  75. conf="$V_HOME/$user/conf/snginx.conf"
  76. str_repl=" proxy_pass https://$ip:$web_ssl_port;"
  77. change_web_config
  78. fi
  79. #----------------------------------------------------------#
  80. # Vesta #
  81. #----------------------------------------------------------#
  82. # Adding suspend in config
  83. update_web_domain_value '$SUSPEND' 'no'
  84. # Adding task to the vesta pipe
  85. restart_schedule 'web'
  86. # Logging
  87. log_event 'system' "$V_EVENT"
  88. exit $OK