From 3840443159987984a08a1f282fd5bdf0e2366913 Mon Sep 17 00:00:00 2001 From: John Supplee Date: Tue, 29 Jan 2019 13:51:18 +0200 Subject: [PATCH] enable setting quotas from the command line --- tools/mail.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/mail.py b/tools/mail.py index 566971e4..7a7b8b8e 100755 --- a/tools/mail.py +++ b/tools/mail.py @@ -57,9 +57,10 @@ def setup_key_auth(mgmt_uri): if len(sys.argv) < 2: print("Usage: ") - print(" tools/mail.py user (lists users)") + print(" tools/mail.py user (lists users with quotas)") print(" tools/mail.py user add user@domain.com [password]") print(" tools/mail.py user password user@domain.com [password]") + print(" tools/mail.py user quota user@domain new-quota") print(" tools/mail.py user remove user@domain.com") print(" tools/mail.py user make-admin user@domain.com") print(" tools/mail.py user remove-admin user@domain.com") @@ -81,6 +82,10 @@ elif sys.argv[1] == "user" and len(sys.argv) == 2: print(user['email'], end='') if "admin" in user['privileges']: print("*", end='') + if user['quota'] == '0': + print(" unlimited", end='') + else: + print(" " + user['quota'], end='') print() elif sys.argv[1] == "user" and sys.argv[2] in ("add", "password"): @@ -116,6 +121,10 @@ elif sys.argv[1] == "user" and sys.argv[2] == "admins": if "admin" in user['privileges']: print(user['email']) +elif sys.argv[1] == "user" and sys.argv[2] == "quota" and len(sys.argv) == 5: + # Set a user's quota + users = mgmt("/mail/users/quota", { "email": sys.argv[3], "quota": sys.argv[4] }) + elif sys.argv[1] == "alias" and len(sys.argv) == 2: print(mgmt("/mail/aliases"))