v_unsuspend_web_domains 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #!/bin/bash
  2. # info: unsuspening web domain (with ssl)
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. # Importing variables
  9. source $VESTA/conf/vars.conf
  10. source $V_FUNC/shared_func.sh
  11. source $V_FUNC/domain_func.sh
  12. #----------------------------------------------------------#
  13. # Verifications #
  14. #----------------------------------------------------------#
  15. # Checking arg number
  16. check_args '1' "$#" 'user'
  17. # Checking argument format
  18. format_validation 'user'
  19. # Checking web system is enabled
  20. is_system_enabled 'web'
  21. # Checking user
  22. is_user_valid
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. # Defining config
  27. conf="$V_USERS/$user/web.conf"
  28. # Defining fileds to select
  29. field='$DOMAIN'
  30. # Defining search string
  31. search_string="SUSPEND='yes'"
  32. # Parsing suspeneded domains
  33. domains=$(dom_clear_search)
  34. # Starting unsuspend loop
  35. for domain in $domains; do
  36. domain_idn=$(idn -t --quiet -a "$domain")
  37. # Get template name
  38. tpl_name=$(get_web_domain_value '$TPL')
  39. tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
  40. # Defining config
  41. conf="$V_HOME/$user/conf/httpd.conf"
  42. # Defining search phrase
  43. search_phrase='Redirect / '
  44. # Defining replace string
  45. str_repl=" DocumentRoot $V_HOME/$user/web/$domain/public_html"
  46. # Unsuspending vhost
  47. change_web_config
  48. # Check ssl vhost
  49. cert=$(get_web_domain_value '$SSL_CERT')
  50. if [ ! -z "$cert" ]; then
  51. # Defining teplate name and ssl documentroot option
  52. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  53. tpl_opt=$(get_web_domain_value '$SSL_HOME')
  54. # Defining config
  55. conf="$V_HOME/$user/conf/shttpd.conf"
  56. # Switching on option
  57. case $tpl_opt in
  58. single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
  59. *) docroot="$V_HOME/$user/web/$domain/public_html" ;;
  60. esac
  61. # Defining replace string
  62. str_repl=" DocumentRoot $docroot"
  63. # Unsuspending vhost
  64. change_web_config
  65. fi
  66. # Check nginx vhost
  67. nginx=$(get_web_domain_value '$NGINX')
  68. if [ ! -z "$nginx" ]; then
  69. ip=$(get_web_domain_value '$IP')
  70. web_port=$(get_config_value '$WEB_PORT')
  71. tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
  72. conf="$V_HOME/$user/conf/nginx.conf"
  73. search_phrase='rewrite ^(.*)$'
  74. str_repl=" proxy_pass http://$ip:$web_port;"
  75. change_web_config
  76. fi
  77. if [ ! -z "$nginx" ] && [ ! -z "$cert" ]; then
  78. web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
  79. tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
  80. conf="$V_HOME/$user/conf/snginx.conf"
  81. str_repl=" proxy_pass https://$ip:$web_ssl_port;"
  82. change_web_config
  83. fi
  84. # Adding unsuspend in config
  85. update_web_domain_value '$SUSPEND' 'no'
  86. done
  87. #----------------------------------------------------------#
  88. # Vesta #
  89. #----------------------------------------------------------#
  90. # Adding task to the vesta pipe
  91. restart_schedule 'web'
  92. # Logging
  93. log_event 'system' "$V_EVENT"
  94. exit $OK