v-unsuspend-domain 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. # info: unsuspend web/dns/mail domain
  3. # options: USER DOMAIN
  4. #
  5. # The function unsuspends 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. #----------------------------------------------------------#
  23. # Action #
  24. #----------------------------------------------------------#
  25. # Working on Web domain
  26. if [ ! -z "$WEB_SYSTEM" ]; then
  27. str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='yes")
  28. if [ ! -z "$str" ]; then
  29. domain_found='yes'
  30. $BIN/v-unsuspend-web-domain $user $domain 'no'
  31. check_result $? "can't suspend web" > /dev/null
  32. fi
  33. fi
  34. # Working on DNS domain
  35. if [ ! -z "$DNS_SYSTEM" ]; then
  36. str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='yes")
  37. if [ ! -z "$str" ]; then
  38. domain_found='yes'
  39. $BIN/v-unsuspend-dns-domain $user $domain 'no'
  40. check_result $? "can't suspend dns" > /dev/null
  41. fi
  42. fi
  43. # Working on Mail domain
  44. if [ ! -z "$MAIL_SYSTEM" ]; then
  45. str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='yes")
  46. if [ ! -z "$str" ]; then
  47. domain_found='yes'
  48. $BIN/v-unsuspend-mail-domain $user $domain
  49. check_result $? "can't suspend mail" > /dev/null
  50. fi
  51. fi
  52. # Checking domain search result
  53. if [ -z "$domain_found" ]; then
  54. echo "Error: domain $domain doesn't exist"
  55. log_event "$E_NOTEXIST" "$ARGUMENTS"
  56. exit $E_NOTEXIST
  57. fi
  58. # Restarting services
  59. $BIN/v-restart-web $restart
  60. check_result $? "can't restart web" > /dev/null
  61. $BIN/v-restart-proxy $restart
  62. check_result $? "can't restart proxy" > /dev/null
  63. $BIN/v-restart-dns $restart
  64. check_result $? "can't restart dns" > /dev/null
  65. #----------------------------------------------------------#
  66. # Vesta #
  67. #----------------------------------------------------------#
  68. exit