v-unsuspend-mail-account 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # info: unsuspend mail account
  3. # options: USER DOMAIN ACCOUNT
  4. #
  5. # The function unsuspends 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_suspended "mail/$domain" 'ACCOUNT' "$account"
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. if [[ "$MAIL_SYSTEM" =~ exim ]]; then
  35. md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
  36. quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA')
  37. sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
  38. str="$account:$md5:$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' 'no'
  46. # Logging
  47. log_event "$OK" "$ARGUMENTS"
  48. exit