myvesta/bin/v-delete-mail-domains
2016-06-09 16:55:35 +03:00

48 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# info: delete mail domains
# options: USER
#
# The function for deleting all users mail domains.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
user=$1
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'USER'
is_format_valid 'user'
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Starting delete loop
for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do
$BIN/v-delete-mail-domain "$user" "$domain"
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$ARGUMENTS"
exit