v-delete-mail-domain-catchall 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 definition
  10. user=$1
  11. domain=$2
  12. # Includes
  13. source $VESTA/func/main.sh
  14. source $VESTA/func/domain.sh
  15. source $VESTA/conf/vesta.conf
  16. # Additional argument formatting
  17. format_domain
  18. format_domain_idn
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '2' "$#" 'USER DOMAIN'
  23. is_format_valid 'user' 'domain'
  24. is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
  25. is_object_valid 'user' 'USER' "$user"
  26. is_object_unsuspended 'user' 'USER' "$user"
  27. is_object_valid 'mail' 'DOMAIN' "$domain"
  28. is_object_unsuspended 'mail' 'DOMAIN' "$domain"
  29. is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL'
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Delete cathcall alias
  34. if [[ "$MAIL_SYSTEM" =~ exim ]]; then
  35. sed -i "/*@$domain_idn:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
  36. fi
  37. #----------------------------------------------------------#
  38. # Vesta #
  39. #----------------------------------------------------------#
  40. # Delete catchall in config
  41. update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' ''
  42. # Logging
  43. log_history "deleted catchall email on $domain"
  44. log_event "$OK" "$ARGUMENTS"
  45. exit