v-suspend-mail-accounts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. # info: suspend all mail domain accounts
  3. # options: USER DOMAIN
  4. #
  5. # The function suspends all mail domain accounts.
  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/conf/vesta.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '2' "$#" 'USER DOMAIN'
  21. is_format_valid 'user' 'domain'
  22. is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
  23. is_object_valid 'user' 'USER' "$user"
  24. is_object_unsuspended 'user' 'USER' "$user"
  25. is_object_valid 'mail' 'DOMAIN' "$domain"
  26. is_object_unsuspended 'mail' 'DOMAIN' "$domain"
  27. #----------------------------------------------------------#
  28. # Action #
  29. #----------------------------------------------------------#
  30. # Starting suspend loop
  31. for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do
  32. $BIN/v-suspend-mail-account "$user" "$domain" "$account"
  33. done
  34. #----------------------------------------------------------#
  35. # Vesta #
  36. #----------------------------------------------------------#
  37. # No Logging
  38. #log_event "$OK" "$ARGUMENTS"
  39. exit