v_delete_mail_domain_antispam 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # info: delete mail domain antispam support
  3. # options: user domain
  4. #
  5. # The function disable spamassasin for incomming emails.
  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. # Importing variables
  15. source $VESTA/conf/vesta.conf
  16. source $VESTA/func/shared.sh
  17. source $VESTA/func/domain.sh
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. # Checking arg number
  22. check_args '2' "$#" 'user domain'
  23. # Checking argument format
  24. validate_format 'user' 'domain'
  25. # Checking dns system is enabled
  26. is_system_enabled 'MAIL_SYSTEM'
  27. # Checking user
  28. is_object_valid 'user' 'USER' "$user"
  29. # Checking user is active
  30. is_object_unsuspended 'user' 'USER' "$user"
  31. # Checking domain
  32. is_domain_valid 'mail'
  33. # Checking domain is not suspened
  34. is_domain_suspended 'mail'
  35. # Checking current value
  36. is_domain_value_exist 'mail' '$ANTISPAM'
  37. #----------------------------------------------------------#
  38. # Action #
  39. #----------------------------------------------------------#
  40. # Delete antispam key
  41. sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection
  42. #----------------------------------------------------------#
  43. # Vesta #
  44. #----------------------------------------------------------#
  45. # Delete antispam in config
  46. update_domain_value 'mail' '$ANTISPAM' 'no'
  47. # Logging
  48. log_history "$EVENT" "v_add_mail_domain_antispam $user $domain"
  49. log_event "$OK" "$EVENT"
  50. exit