v-suspend-domain 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. # info: suspend web/dns/mail domain
  3. # options: USER DOMAIN
  4. #
  5. # The function suspends 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 |grep "SUSPENDED='no")
  29. if [ ! -z "$str" ]; then
  30. domain_found='yes'
  31. $BIN/v-suspend-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 |grep "SUSPENDED='no")
  38. if [ ! -z "$str" ]; then
  39. domain_found='yes'
  40. $BIN/v-suspend-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 |grep "SUSPENDED='no")
  47. if [ ! -z "$str" ]; then
  48. domain_found='yes'
  49. $BIN/v-suspend-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. echo "Error: domain $domain doesn't exist"
  56. log_event "$E_NOTEXIST" "$ARGUMENTS"
  57. exit $E_NOTEXIST
  58. fi
  59. # Restarting services
  60. $BIN/v-restart-web $restat
  61. check_result $? "can't restart web" > /dev/null
  62. $BIN/v-restart-proxy $restart
  63. check_result $? "can't restart proxy" > /dev/null
  64. $BIN/v-restart-dns $restart
  65. check_result $? "can't restart dns" > /dev/null
  66. #----------------------------------------------------------#
  67. # Vesta #
  68. #----------------------------------------------------------#
  69. exit