v-unsuspend-web-domain 2.4 KB

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