v_del_web_domain 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. # info: deliting web domain
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. domain=$(idn -t --quiet -u "$2" )
  9. domain_idn=$(idn -t --quiet -a "$domain")
  10. # Importing variables
  11. source $VESTA/conf/vars.conf
  12. source $V_FUNC/shared_func.sh
  13. source $V_FUNC/domain_func.sh
  14. source $V_FUNC/ip_func.sh
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. # Checking arg number
  19. check_args '2' "$#" 'user domain'
  20. # Checking argument format
  21. format_validation 'user' 'domain'
  22. # Checking web system is enabled
  23. is_system_enabled 'web'
  24. # Checking user
  25. is_user_valid
  26. # Checking user is active
  27. is_user_suspended
  28. # Checking domain exist
  29. is_web_domain_valid
  30. # Checking domain is not suspened
  31. is_domain_suspended 'web_domains'
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. # Get template name
  36. tpl_name=$(get_web_domain_value '$TPL')
  37. old_ip=$(get_web_domain_value '$IP')
  38. tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
  39. conf="$V_HOME/$user/conf/httpd.conf"
  40. # Deleting domain
  41. del_web_config
  42. exit
  43. # Checking ssl
  44. cert=$(get_web_domain_value '$SSL_CERT')
  45. if [ ! -z "$cert" ]; then
  46. # Get tpl
  47. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  48. conf="$V_HOME/$user/conf/shttpd.conf"
  49. # Deleting domain
  50. del_web_config
  51. fi
  52. # Checking stats
  53. stats_type=$(get_web_domain_value '$STATS')
  54. if [ ! -z "$stats_type" ] && [ "$stats_type" != 'no' ]; then
  55. # Parsing pipe line
  56. line=$(grep -n "$type.$domain.conf" $V_QUEUE/stats.pipe | \
  57. cut -f 1 -d : | head -n 1 )
  58. # Deleting pipe command
  59. if [ ! -z "$line" ]; then
  60. sed -i "$line d" $V_QUEUE/stats.pipe
  61. fi
  62. # Deleteing config
  63. rm -f $V_HOME/$user/conf/$type.$domain.conf
  64. fi
  65. # Deleting directory
  66. rm -rf $V_HOME/$user/domains/$domain
  67. # Deleting logs
  68. rm -rf /var/log/httpd/domains/$domain.log*
  69. rm -rf /var/log/httpd/domains/$domain.bytes
  70. rm -rf /var/log/httpd/domains/$domain.error*
  71. #----------------------------------------------------------#
  72. # Vesta #
  73. #----------------------------------------------------------#
  74. # Deleting domain
  75. del_web_domain
  76. # Checking last ssl domain
  77. ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web_domains.conf | wc -l)
  78. if [ "$ssl_dom" -eq '0' ]; then
  79. sed -i "s/ Include /#Include /" $V_HOME/$user/conf/httpd.conf
  80. fi
  81. # Checking last domain
  82. domains=$(wc -l $V_USERS/$user/web_domains.conf|cut -f 1 -d ' ')
  83. if [ "$domains" -eq '0' ]; then
  84. conf='/etc/httpd/conf.d/vesta.conf'
  85. line=$(grep -n "$V_HOME/$user/conf/httpd.conf" $conf | cut -f 1 -d : )
  86. if [ ! -z "$line" ]; then
  87. sed -i "$line d" $conf
  88. fi
  89. fi
  90. # Decreasing ip value
  91. decrease_ip_value "$old_ip"
  92. # Decreasing domain value
  93. decrease_user_value "$user" '$U_WEB_DOMAINS'
  94. # Adding task to the vesta pipe
  95. restart_schedule 'web'
  96. # Logging
  97. log_history "$V_EVENT"
  98. log_event 'system' "$V_EVENT"
  99. exit $OK