v-suspend-domain 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. if [ "$restart" != 'no' ]; then
  61. $BIN/v-restart-web
  62. check_result $? "can't restart web" > /dev/null
  63. if [ ! -z "$PROXY_SYSTEM" ]; then
  64. $BIN/v-restart-proxy
  65. check_result $? "can't restart proxy" > /dev/null
  66. fi
  67. $BIN/v-restart-dns
  68. check_result $? "can't restart dns" > /dev/null
  69. fi
  70. #----------------------------------------------------------#
  71. # Vesta #
  72. #----------------------------------------------------------#
  73. exit