v-suspend-web-domain 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. # info: suspend web domain
  3. # options: USER DOMAIN
  4. #
  5. # The function for suspending the site's operation. After blocking it all
  6. # visitors will be redirected to a web page explaining the reason of suspend.
  7. # By blocking the site the content of all its directories remains untouched.
  8. #----------------------------------------------------------#
  9. # Variable&Function #
  10. #----------------------------------------------------------#
  11. # Argument defenition
  12. user=$1
  13. domain=$(idn -t --quiet -u "$2" )
  14. domain_idn=$(idn -t --quiet -a "$domain")
  15. restart=$3
  16. # Includes
  17. source $VESTA/func/main.sh
  18. source $VESTA/func/domain.sh
  19. source $VESTA/func/ip.sh
  20. source $VESTA/conf/vesta.conf
  21. #----------------------------------------------------------#
  22. # Verifications #
  23. #----------------------------------------------------------#
  24. check_args '2' "$#" 'USER DOMAIN [RESTART]'
  25. validate_format '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_unsuspended 'web' 'DOMAIN' "$domain"
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Parsing domain values
  34. get_domain_values 'web'
  35. tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.tpl"
  36. conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
  37. SUSPENDED='yes'
  38. ip=$(get_real_ip $IP)
  39. # Preparing domain values for the template substitution
  40. upd_web_domain_values
  41. # Recreating vhost
  42. del_web_config
  43. add_web_config
  44. # Check SSL
  45. if [ "$SSL" = 'yes' ]; then
  46. tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
  47. conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
  48. del_web_config
  49. add_web_config
  50. fi
  51. # Checking proxy
  52. if [ ! -z "$PROXY" ]; then
  53. tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
  54. conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
  55. del_web_config
  56. add_web_config
  57. fi
  58. # Checking proxy SSL
  59. if [ ! -z "$PROXY" ] && [ "$SSL" = 'yes' ]; then
  60. tpl_file="$WEBTPL/$PROXY_SSL/$PROXY.stpl"
  61. conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
  62. del_web_config
  63. add_web_config
  64. fi
  65. #----------------------------------------------------------#
  66. # Vesta #
  67. #----------------------------------------------------------#
  68. # Update config
  69. update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
  70. increase_user_value "$user" '$SUSPENDED_WEB'
  71. # Restart web server
  72. if [ "$restart" != 'no' ]; then
  73. $BIN/v-restart-web
  74. if [ $? -ne 0 ]; then
  75. exit E_RESTART
  76. fi
  77. $BIN/v-restart-proxy
  78. if [ $? -ne 0 ]; then
  79. exit E_RESTART
  80. fi
  81. fi
  82. # Logging
  83. log_event "$OK" "$EVENT"
  84. exit