v-delete-mail-domain-catchall 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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=$(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/func/main.sh
  16. source $VESTA/func/domain.sh
  17. source $VESTA/conf/vesta.conf
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '2' "$#" 'USER DOMAIN'
  22. is_format_valid 'user' 'domain'
  23. is_system_enabled "$MAIL_SYSTEM" '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. if [[ "$MAIL_SYSTEM" =~ exim ]]; then
  34. sed -i "/*@$domain_idn:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
  35. fi
  36. #----------------------------------------------------------#
  37. # Vesta #
  38. #----------------------------------------------------------#
  39. # Delete catchall in config
  40. update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' ''
  41. # Logging
  42. log_history "deleted catchall email on $domain"
  43. log_event "$OK" "$ARGUMENTS"
  44. exit