v-delete-mail-domain-catchall 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # info: delete mail domain catchall email
  3. # options: user domain
  4. #
  5. # The function disables mail domain cathcall.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. domain=$(idn -t --quiet -u "$2" )
  12. domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
  13. domain_idn=$(idn -t --quiet -a "$domain")
  14. # Includes
  15. source $VESTA/conf/vesta.conf
  16. source $VESTA/func/main.sh
  17. source $VESTA/func/domain.sh
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '2' "$#" 'user domain'
  22. validate_format 'user' 'domain'
  23. is_system_enabled "$MAIL_SYSTEM"
  24. is_object_valid 'user' 'USER' "$user"
  25. is_object_unsuspended 'user' 'USER' "$user"
  26. is_object_valid 'mail' 'DOMAIN' "$domain"
  27. is_object_unsuspended 'mail' 'DOMAIN' "$domain"
  28. is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL'
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Delete cathcall alias
  33. sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
  34. #----------------------------------------------------------#
  35. # Vesta #
  36. #----------------------------------------------------------#
  37. # Delete catchall in config
  38. update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' ''
  39. # Logging
  40. log_history "delted catchall email on $domain"
  41. log_event "$OK" "$EVENT"
  42. exit