v-unsuspend-web-domain 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. source $VESTA/func/ip.sh
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '2' "$#" 'USER DOMAIN [RESTART]'
  23. validate_format 'user' 'domain'
  24. is_system_enabled "$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. tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.tpl"
  34. conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
  35. SUSPENDED='no'
  36. ip=$(get_real_ip $IP)
  37. # Preparing domain values for the template substitution
  38. upd_web_domain_values
  39. # Recreating vhost
  40. del_web_config
  41. add_web_config
  42. # Check SSL
  43. if [ "$SSL" = 'yes' ]; then
  44. tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
  45. conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
  46. del_web_config
  47. add_web_config
  48. fi
  49. # Checking proxy
  50. if [ ! -z "$PROXY" ]; then
  51. tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
  52. conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
  53. del_web_config
  54. add_web_config
  55. fi
  56. # Checking SSL proxy
  57. if [ ! -z "$PROXY" ] && [ "$SSL" = 'yes' ]; then
  58. tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
  59. conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
  60. del_web_config
  61. add_web_config
  62. fi
  63. #----------------------------------------------------------#
  64. # Vesta #
  65. #----------------------------------------------------------#
  66. # Update config
  67. update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
  68. decrease_user_value "$user" '$SUSPENDED_WEB'
  69. # Restart web erver
  70. if [ "$restart" != 'no' ]; then
  71. $BIN/v-restart-web
  72. $BIN/v-restart-proxy
  73. fi
  74. # Logging
  75. log_event "$OK" "$EVENT"
  76. exit