v-suspend-mail-account 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. # info: suspend mail account
  3. # options: USER DOMAIN ACCOUNT
  4. #
  5. # The function suspends mail account.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. domain=$2
  12. account=$3
  13. # Includes
  14. source $VESTA/func/main.sh
  15. source $VESTA/func/domain.sh
  16. source $VESTA/conf/vesta.conf
  17. # Additional argument formatting
  18. format_domain
  19. format_domain_idn
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. check_args '3' "$#" 'USER DOMAIN ACCOUNT'
  24. is_format_valid 'user' 'domain' 'account'
  25. is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
  26. is_object_valid 'user' 'USER' "$user"
  27. is_object_unsuspended 'user' 'USER' "$user"
  28. is_object_valid 'mail' 'DOMAIN' "$domain"
  29. is_object_unsuspended 'mail' 'DOMAIN' "$domain"
  30. is_object_valid "mail/$domain" 'ACCOUNT' "$account"
  31. is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. if [[ "$MAIL_SYSTEM" =~ exim ]]; then
  36. quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA')
  37. sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
  38. str="$account:SUSPENDED:$user:mail::$HOMEDIR/$user:$quota"
  39. echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
  40. fi
  41. #----------------------------------------------------------#
  42. # Vesta #
  43. #----------------------------------------------------------#
  44. # Update config
  45. update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'yes'
  46. # Logging
  47. log_event "$OK" "$ARGUMENTS"
  48. exit