mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-22 21:40:20 -08:00
98 lines
2.5 KiB
Bash
Executable File
98 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: list mail domain
|
|
# options: USER DOMAIN [FORMAT]
|
|
#
|
|
# The function of obtaining the list of domain parameters.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
user=$1
|
|
domain=$2
|
|
format=${3-shell}
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
|
|
# JSON list function
|
|
json_list() {
|
|
eval $(grep "DOMAIN='$domain'" $USER_DATA/mail.conf)
|
|
echo '{'
|
|
echo ' "'$DOMAIN'": {
|
|
"ANTIVIRUS": "'$ANTIVIRUS'",
|
|
"ANTISPAM": "'$ANTISPAM'",
|
|
"DKIM": "'$DKIM'",
|
|
"CATCHALL": "'$CATCHALL'",
|
|
"ACCOUNTS": "'$ACCOUNTS'",
|
|
"U_DISK": "'$U_DISK'",
|
|
"SUSPENDED": "'$SUSPENDED'",
|
|
"TIME": "'$TIME'",
|
|
"DATE": "'$DATE'"
|
|
}'
|
|
echo '}'
|
|
}
|
|
|
|
# SHELL list function
|
|
shell_list() {
|
|
echo "DOMAIN: $DOMAIN"
|
|
echo "ANTIVIRUS: $ANTIVIRUS"
|
|
echo "ANTISPAM: $ANTISPAM"
|
|
echo "DKIM: $DKIM"
|
|
echo "CATCHALL: $CATCHALL"
|
|
echo "ACCOUNTS: $ACCOUNTS"
|
|
echo "DISK: $U_DISK"
|
|
echo "SUSPENDED: $SUSPENDED"
|
|
echo "TIME: $TIME"
|
|
echo "DATE: $DATE"
|
|
}
|
|
|
|
# PLAIN list function
|
|
plain_list() {
|
|
echo -ne "$DOMAIN\t$ANTIVIRUS\t$ANTISPAM\t$DKIM\t$CATCHALL\t"
|
|
echo -e "$ACCOUNTS\t$U_DISK\t$SUSPENDED\t$TIME\t$DATE"
|
|
}
|
|
|
|
# CSV list function
|
|
csv_list() {
|
|
echo -n "DOMAIN,ANTIVIRUS,ANTISPAM,DKIM,CATCHALL,ACCOUNTS,U_DISK,"
|
|
echo "SUSPENDED,TIME,DATE"
|
|
echo -n "$DOMAIN,$ANTIVIRUS,$ANTISPAM,$DKIM,$CATCHALL,$ACCOUNTS,$U_DISK"
|
|
echo "$SUSPENDED,$TIME,$DATE"
|
|
}
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '2' "$#" 'USER DOMAIN [FORMAT]'
|
|
is_format_valid 'user' 'domain'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_valid 'mail' 'DOMAIN' "$domain"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Parsing mail domain
|
|
eval $(grep "DOMAIN='$domain'" $USER_DATA/mail.conf)
|
|
|
|
# Listing data
|
|
case $format in
|
|
json) json_list ;;
|
|
plain) plain_list ;;
|
|
csv) csv_list ;;
|
|
shell) shell_list ;;
|
|
esac
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
exit
|