v-delete-web-domain-proxy 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 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/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. del_web_config
  37. # Checking SSL
  38. if [ "$SSL" = 'yes' ]; then
  39. tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
  40. conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
  41. del_web_config
  42. fi
  43. #----------------------------------------------------------#
  44. # Vesta #
  45. #----------------------------------------------------------#
  46. # Update config
  47. update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' ''
  48. update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' ''
  49. # Checking last SSL proxy
  50. conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
  51. last_sproxy=$(grep "SSL='yes'" $USER_DATA/web.conf)
  52. if [ -z "$last_sproxy" ]; then
  53. sed -i "/.*\/$user\/.*s$PROXY_SYSTEM.conf/d" $conf
  54. rm -f $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf
  55. fi
  56. # Checking last proxy
  57. last_proxy=$(grep -v "PROXY=''" $USER_DATA/web.conf)
  58. if [ -z "$last_proxy" ]; then
  59. sed -i "/.*\/$user\/.*$PROXY_SYSTEM.conf/d" $conf
  60. rm -f $HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf
  61. fi
  62. # Restart proxy server
  63. if [ "$restart" != 'no' ]; then
  64. $BIN/v-restart-proxy
  65. if [ $? -ne 0 ]; then
  66. exit E_RESTART
  67. fi
  68. fi
  69. # Logging
  70. log_history "disabled proxy support for $domain"
  71. log_event "$OK" "$EVENT"
  72. exit