forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_list_mail_account_autoreply
More file actions
executable file
·72 lines (56 loc) · 1.84 KB
/
Copy pathv_list_mail_account_autoreply
File metadata and controls
executable file
·72 lines (56 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# info: list mail account autoreply
# options: user domain account [format]
#
# The function of obtainin mail account autoreply message.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$2
account=$3
format=${4-shell}
# Includes
source $VESTA/func/main.sh
# Json function
json_list_msg() {
i='1' # iterator
echo '{'
echo -e "\t\"$account\": {"
echo " \"MSG\": \"$msg\""
echo -e "\t}\n}"
}
# Shell function
shell_list_msg() {
if [ ! -z "$msg" ]; then
echo -e "$msg"
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user domain [format]'
is_object_valid '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"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ -e "$USER_DATA/mail/$account@$domain.msg" ]; then
msg=$(cat $USER_DATA/mail/$account@$domain.msg |\
sed -e ':a;N;$!ba;s/\n/\\n/g' )
fi
# Listing domains
case $format in
json) json_list_msg ;;
plain) nohead=1; shell_list_msg ;;
shell) shell_list_msg ;;
*) check_args '1' '0' '[format]'
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit