v_del_web_domain 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. httpd_del_config
  42. # Checking ssl
  43. ssl=$(get_web_domain_value '$SSL')
  44. if [ "$ssl" = 'yes' ]; then
  45. # Get tpl
  46. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  47. conf="$V_HOME/$user/conf/shttpd.conf"
  48. # Deleting domain
  49. httpd_del_config
  50. fi
  51. # Checking stats
  52. stats_type=$(get_web_domain_value '$STATS')
  53. if [ ! -z "$stats_type" ] && [ "$stats_type" != 'no' ]; then
  54. # Parsing pipe line
  55. line=$(grep -n "$type.$domain.conf" $V_QUEUE/stats.pipe | \
  56. cut -f 1 -d : | head -n 1 )
  57. # Deleting pipe command
  58. if [ ! -z "$line" ]; then
  59. sed -i "$line d" $V_QUEUE/stats.pipe
  60. fi
  61. # Deleteing config
  62. rm -f $V_HOME/$user/conf/$type.$domain.conf
  63. fi
  64. # Deleting directory
  65. rm -rf $V_HOME/$user/domains/$domain
  66. #----------------------------------------------------------#
  67. # Vesta #
  68. #----------------------------------------------------------#
  69. # Deleting domain
  70. del_web_domain
  71. # Checking last ssl domain
  72. ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web_domains.conf | wc -l)
  73. if [ "$ssl_dom" -eq '0' ]; then
  74. sed -i "s/ Include /#Include /" $V_HOME/$user/conf/httpd.conf
  75. fi
  76. # Checking last domain
  77. domains=$(wc -l $V_USERS/$user/web_domains.conf|cut -f 1 -d ' ')
  78. if [ "$domains" -eq '0' ]; then
  79. conf='/etc/httpd/conf.d/vesta.conf'
  80. line=$(grep -n "$V_HOME/$user/conf/httpd.conf" $conf | cut -f 1 -d : )
  81. if [ ! -z "$line" ]; then
  82. sed -i "$line d" $conf
  83. fi
  84. fi
  85. # Decreasing ip value
  86. decrease_ip_value "$old_ip"
  87. # Decreasing domain value
  88. decrease_user_value "$user" '$U_WEB_DOMAINS'
  89. # Adding task to the vesta pipe
  90. restart_schedule 'web'
  91. # Logging
  92. log_history "$V_EVENT"
  93. log_event 'system' "$V_EVENT"
  94. exit $OK