v-delete-web-domain-proxy 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. # info: deleting web domain proxy configuration
  3. # options: USER DOMAIN
  4. #
  5. # The function of deleting the virtualhost proxy configuration.
  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/conf/vesta.conf
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '2' "$#" 'USER DOMAIN'
  22. validate_format 'user' 'domain'
  23. is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
  24. is_object_valid 'user' 'USER' "$user"
  25. is_object_unsuspended 'user' 'USER' "$user"
  26. is_object_valid 'web' 'DOMAIN' "$domain"
  27. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  28. is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Defining domain parameters
  33. get_domain_values 'web'
  34. tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
  35. conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
  36. if [ ! -z "$PROXY_SYSTEM" ]; then
  37. del_web_config
  38. fi
  39. # Checking SSL
  40. if [ "$SSL" = 'yes' ]; then
  41. tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
  42. conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
  43. if [ ! -z "$PROXY_SYSTEM" ]; then
  44. del_web_config
  45. fi
  46. fi
  47. #----------------------------------------------------------#
  48. # Vesta #
  49. #----------------------------------------------------------#
  50. # Update config
  51. update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' ''
  52. update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' ''
  53. if [ -z "$PROXY_SYSTEM" ]; then
  54. exit
  55. fi
  56. # Checking last SSL proxy
  57. conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
  58. last_sproxy=$(grep "SSL='yes'" $USER_DATA/web.conf)
  59. if [ -z "$last_sproxy" ]; then
  60. sed -i "/.*\/$user\/.*s$PROXY_SYSTEM.conf/d" $conf
  61. rm -f $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf
  62. fi
  63. # Checking last proxy
  64. last_proxy=$(grep -v "PROXY=''" $USER_DATA/web.conf)
  65. if [ -z "$last_proxy" ]; then
  66. sed -i "/.*\/$user\/.*$PROXY_SYSTEM.conf/d" $conf
  67. rm -f $HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf
  68. fi
  69. # Restart proxy server
  70. if [ "$restart" != 'no' ]; then
  71. $BIN/v-restart-proxy
  72. check_result $? "Proxy restart failed" >/dev/null
  73. fi
  74. # Logging
  75. log_history "disabled proxy support for $domain"
  76. log_event "$OK" "$EVENT"
  77. exit