v_unsuspend_web_domain 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # info: unsuspend web domain
  3. # options: user domain
  4. #
  5. # The function of unsuspending the domain.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. domain=$(idn -t --quiet -u "$2" )
  12. domain_idn=$(idn -t --quiet -a "$domain")
  13. restart="$3"
  14. # Includes
  15. source $VESTA/conf/vesta.conf
  16. source $VESTA/func/main.sh
  17. source $VESTA/func/domain.sh
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '2' "$#" 'user domain'
  22. validate_format 'user' 'domain'
  23. is_system_enabled "$WEB_SYSTEM"
  24. is_object_valid 'user' 'USER' "$user"
  25. is_object_valid 'web' 'DOMAIN' "$domain"
  26. is_object_suspended 'web' 'DOMAIN' "$domain"
  27. #----------------------------------------------------------#
  28. # Action #
  29. #----------------------------------------------------------#
  30. # Parsing domain values
  31. get_domain_values 'web'
  32. tpl_file="$WEBTPL/apache_$TPL.tpl"
  33. conf="$HOMEDIR/$user/conf/web/httpd.conf"
  34. SUSPENDED='no'
  35. # Preparing domain values for the template substitution
  36. upd_web_domain_values
  37. # Recreating vhost
  38. del_web_config
  39. add_web_config
  40. # Check ssl
  41. if [ "$SSL" = 'yes' ]; then
  42. tpl_file="$WEBTPL/apache_$TPL.stpl"
  43. conf="$HOMEDIR/$user/conf/web/shttpd.conf"
  44. del_web_config
  45. add_web_config
  46. fi
  47. # Checking nginx
  48. if [ ! -z "$NGINX" ]; then
  49. tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
  50. conf="$HOMEDIR/$user/conf/web/nginx.conf"
  51. del_web_config
  52. add_web_config
  53. if [ "$SSL" = 'yes' ]; then
  54. proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
  55. tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
  56. conf="$HOMEDIR/$user/conf/web/snginx.conf"
  57. del_web_config
  58. add_web_config
  59. fi
  60. fi
  61. #----------------------------------------------------------#
  62. # Vesta #
  63. #----------------------------------------------------------#
  64. # Update config
  65. update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
  66. decrease_user_value "$user" '$SUSPENDED_WEB'
  67. # Restart web erver
  68. if [ "$restart" != 'no' ]; then
  69. $BIN/v_restart_web "$EVENT"
  70. fi
  71. # Logging
  72. log_event "$OK" "$EVENT"
  73. exit