v-unsuspend-web-domain 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 definition
  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/func/main.sh
  16. source $VESTA/func/domain.sh
  17. source $VESTA/func/ip.sh
  18. source $VESTA/conf/vesta.conf
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '2' "$#" 'USER DOMAIN [RESTART]'
  23. is_format_valid 'user' 'domain'
  24. is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
  25. is_object_valid 'user' 'USER' "$user"
  26. is_object_valid 'web' 'DOMAIN' "$domain"
  27. is_object_suspended 'web' 'DOMAIN' "$domain"
  28. #----------------------------------------------------------#
  29. # Action #
  30. #----------------------------------------------------------#
  31. # Parsing domain values
  32. get_domain_values 'web'
  33. SUSPENDED='no'
  34. local_ip=$(get_real_ip $IP)
  35. # Preparing domain values for the template substitution
  36. prepare_web_domain_values
  37. # Rebuilding vhost
  38. del_web_config "$WEB_SYSTEM" "$TPL.tpl"
  39. add_web_config "$WEB_SYSTEM" "$TPL.tpl"
  40. if [ "$SSL" = 'yes' ]; then
  41. del_web_config "$WEB_SYSTEM" "$TPL.stpl"
  42. add_web_config "$WEB_SYSTEM" "$TPL.stpl"
  43. fi
  44. # Rebuilding proxy configuration
  45. if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
  46. del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
  47. add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
  48. if [ "$SSL" = 'yes' ]; then
  49. del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
  50. add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
  51. fi
  52. fi
  53. #----------------------------------------------------------#
  54. # Vesta #
  55. #----------------------------------------------------------#
  56. # Updating config
  57. update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
  58. decrease_user_value "$user" '$SUSPENDED_WEB'
  59. # Restarting web server
  60. if [ "$restart" != 'no' ]; then
  61. $BIN/v-restart-web
  62. check_result $? "Web restart failed" >/dev/null
  63. if [ ! -z "$PROXY_SYSTEM" ]; then
  64. $BIN/v-restart-proxy
  65. check_result $? "Proxy restart failed" >/dev/null
  66. fi
  67. fi
  68. # Logging
  69. log_event "$OK" "$ARGUMENTS"
  70. exit