v-delete-domain 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. # info: delete web/dns/mail domain
  3. # options: USER DOMAIN
  4. #
  5. # The function deletes web/dns/mail domain.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. domain=$2
  12. restart="${3-yes}"
  13. # Includes
  14. source $VESTA/func/main.sh
  15. source $VESTA/conf/vesta.conf
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '2' "$#" 'USER DOMAIN'
  20. is_format_valid 'user' 'domain'
  21. is_object_valid 'user' 'USER' "$user"
  22. is_object_unsuspended 'user' 'USER' "$user"
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. # Working on Web domain
  27. if [ ! -z "$WEB_SYSTEM" ]; then
  28. str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
  29. if [ ! -z "$str" ]; then
  30. domain_found='yes'
  31. $BIN/v-delete-web-domain $user $domain 'no'
  32. check_result $? "can't suspend web" > /dev/null
  33. fi
  34. fi
  35. # Working on DNS domain
  36. if [ ! -z "$DNS_SYSTEM" ]; then
  37. str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
  38. if [ ! -z "$str" ]; then
  39. domain_found='yes'
  40. $BIN/v-delete-dns-domain $user $domain 'no'
  41. check_result $? "can't suspend dns" > /dev/null
  42. fi
  43. fi
  44. # Working on Mail domain
  45. if [ ! -z "$MAIL_SYSTEM" ]; then
  46. str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf)
  47. if [ ! -z "$str" ]; then
  48. domain_found='yes'
  49. $BIN/v-delete-mail-domain $user $domain
  50. check_result $? "can't suspend mail" > /dev/null
  51. fi
  52. fi
  53. # Checking domain search result
  54. if [ -z "$domain_found" ]; then
  55. check_result $E_NOTEXISTS "domain $domain doesn't exist"
  56. fi
  57. # Restarting services
  58. if [ "$restart" != 'no' ]; then
  59. $BIN/v-restart-web
  60. check_result $? "can't restart web" > /dev/null
  61. if [ ! -z "$PROXY_SYSTEM" ]; then
  62. $BIN/v-restart-proxy
  63. check_result $? "can't restart proxy" > /dev/null
  64. fi
  65. $BIN/v-restart-dns
  66. check_result $? "can't restart dns" > /dev/null
  67. fi
  68. #----------------------------------------------------------#
  69. # Vesta #
  70. #----------------------------------------------------------#
  71. exit