1
0
mirror of https://github.com/myvesta/vesta.git synced 2025-03-11 12:02:42 -07:00
myvesta/bin/v-add-mail-account-alias

75 lines
2.1 KiB
Plaintext
Raw Normal View History

2013-01-19 23:07:26 +02:00
#!/bin/bash
# info: add mail account alias aka nickname
# options: USER DOMAIN ACCOUNT ALIAS
#
# The function add new email alias.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2013-01-19 23:07:26 +02:00
user=$1
domain=$2
2017-03-05 23:34:07 +01:00
domain_idn=$2
2013-01-19 23:07:26 +02:00
account=$3
malias=$4
# Includes
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
source $VESTA/conf/vesta.conf
2013-01-19 23:07:26 +02:00
# Additional argument formatting
format_domain
format_domain_idn
2017-03-05 23:34:07 +01:00
# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ?
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS'
is_format_valid 'user' 'domain' 'account' 'malias'
2013-05-29 13:16:09 +03:00
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
2013-01-19 23:07:26 +02:00
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
is_mail_new "$malias"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Adding exim alias
2014-04-01 23:51:10 +03:00
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
str="$malias@$domain_idn:$account@$domain_idn"
2014-04-01 23:51:10 +03:00
echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases
fi
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Adding vesta alias
aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS')
if [ -z "$aliases" ]; then
aliases="$malias"
else
aliases="$aliases,$malias"
fi
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases"
# Logging
log_history "added alias $malias to $account@$domain "
log_event "$OK" "$ARGUMENTS"
2013-01-19 23:07:26 +02:00
exit