forked from stsimb/zimbra-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zimbra-quota.sh
executable file
·47 lines (40 loc) · 1.19 KB
/
zimbra-quota.sh
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
#!/bin/bash
# a zimbra mailbox server to make admin requests (can be localhost or remote)
ZADMIN="https://zm-mbox-01:7071"
# set default quota in MB
DEFAULTQUOTA=3072
# exit if no param
if [ "x$1" == "x" ]; then
echo "USAGE = $0 username [newQuota]"
exit 1
fi
# if second param given, skip interactive part
if [ "x$2" != "x" ]; then
newQuota=$2
else
# get current mailbox usage
echo -n "Current usage: "
size="$(zmmailbox -u ${ZADMIN} -z -m $1 gms || echo 0)"
echo "${size}"
# get current quota
echo -n "Current quota: "
actualQuota="$((zmprov ga $1 zimbraMailQuota || echo 0) | grep -v "#" |cut -d ":" -f 2 | head -n 1|sed -e 's/ //g')"
let dispQuota=$actualQuota/1024/1024
echo "$dispQuota MB"
# read new quota
echo -n "New Quota (in MB)? "
read newQuota
fi
# cancel if no input
if [ "x${newQuota}" == "x" ]; then
echo "cancel, keeping existing quota."
exit
fi
let newQuota=$newQuota*1024*1024
# issue warning if new quota is below our default
if [ ${newQuota} -lt $((${DEFAULTQUOTA}*1024*1024)) ]; then
echo "WARNING: setting quota below our default (${DEFAULTQUOTA} MB)"
fi
# change the quota
zmprov ma $1 zimbraMailQuota $newQuota
echo "New quota for $1 = $((${newQuota}/1024/1024)) MB"