| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/bin/bash
- # info: change mail domain catchall email
- # options: user domain email
- #
- # The function changes mail domain cathcall.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument defenition
- user=$1
- domain=$(idn -t --quiet -u "$2" )
- domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
- domain_idn=$(idn -t --quiet -a "$domain")
- email="$3"
- # Includes
- source $VESTA/conf/vesta.conf
- source $VESTA/func/main.sh
- source $VESTA/func/domain.sh
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- check_args '3' "$#" 'user domain email'
- validate_format 'user' 'domain' 'email'
- is_system_enabled "$MAIL_SYSTEM"
- is_object_valid 'user' 'USER' "$user"
- is_object_unsuspended 'user' 'USER' "$user"
- is_object_valid 'mail' 'DOMAIN' "$domain"
- is_object_unsuspended 'mail' 'DOMAIN' "$domain"
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Change cathcall alias
- sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
- echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- # Change catchall in config
- update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email"
- # Logging
- log_history "$EVENT"
- log_event "$OK" "$EVENT"
- exit
|