v-unsuspend-mail-domain 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # info: unsuspend mail domain
  3. # options: USER DOMAIN
  4. #
  5. # The function unsuspends mail domain.
  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/func/domain.sh
  17. source $VESTA/conf/vesta.conf
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '2' "$#" 'USER DOMAIN'
  22. is_format_valid 'user' 'domain'
  23. is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
  24. is_object_valid 'user' 'USER' "$user"
  25. is_object_valid 'mail' 'DOMAIN' "$domain"
  26. is_object_suspended 'mail' 'DOMAIN' "$domain"
  27. #----------------------------------------------------------#
  28. # Action #
  29. #----------------------------------------------------------#
  30. # Add symbolic link
  31. if [[ "$MAIL_SYSTEM" =~ exim ]]; then
  32. ln -s $HOMEDIR/$user/conf/mail/$domain /etc/$MAIL_SYSTEM/domains/
  33. fi
  34. #----------------------------------------------------------#
  35. # Vesta #
  36. #----------------------------------------------------------#
  37. # Updating config
  38. update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
  39. sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/mail/$domain.conf
  40. decrease_user_value "$user" '$SUSPENDED_MAIL'
  41. # Logging
  42. log_event "$OK" "$ARGUMENTS"
  43. exit