v-unsuspend-web-domain 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 [restart]'
  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/nginx_$NGINX.tpl"
  50. conf="$HOMEDIR/$user/conf/web/nginx.conf"
  51. del_web_config
  52. add_web_config
  53. if [ "$SSL" = 'yes' ]; then
  54. tpl_file="$WEBTPL/nginx_$NGINX.stpl"
  55. conf="$HOMEDIR/$user/conf/web/snginx.conf"
  56. del_web_config
  57. add_web_config
  58. fi
  59. fi
  60. #----------------------------------------------------------#
  61. # Vesta #
  62. #----------------------------------------------------------#
  63. # Update config
  64. update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
  65. decrease_user_value "$user" '$SUSPENDED_WEB'
  66. # Restart web erver
  67. if [ "$restart" != 'no' ]; then
  68. $BIN/v-restart-web "$EVENT"
  69. fi
  70. # Logging
  71. log_event "$OK" "$EVENT"
  72. exit