v-suspend-mail-account 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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=$(idn -t --quiet -u "$2" )
  12. domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
  13. domain_idn=$(idn -t --quiet -a "$domain")
  14. account=$3
  15. # Includes
  16. source $VESTA/func/main.sh
  17. source $VESTA/func/domain.sh
  18. source $VESTA/conf/vesta.conf
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '3' "$#" 'USER DOMAIN ACCOUNT'
  23. is_format_valid 'user' 'domain' 'account'
  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_valid "mail/$domain" 'ACCOUNT' "$account"
  30. is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. if [[ "$MAIL_SYSTEM" =~ exim ]]; then
  35. quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA')
  36. sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
  37. str="$account:SUSPENDED:$user:mail::$HOMEDIR/$user:$quota"
  38. echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
  39. fi
  40. #----------------------------------------------------------#
  41. # Vesta #
  42. #----------------------------------------------------------#
  43. # Update config
  44. update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'yes'
  45. # Logging
  46. log_event "$OK" "$ARGUMENTS"
  47. exit