From 8c69f012a0ee752595e919799246a9d883774c1f Mon Sep 17 00:00:00 2001 From: pierreozoux Date: Mon, 4 Jul 2016 20:39:23 +0100 Subject: [PATCH] Auto provision domain name if it doesn't exist --- utils/add_user | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/add_user b/utils/add_user index 4482f9b..161588c 100755 --- a/utils/add_user +++ b/utils/add_user @@ -11,6 +11,11 @@ local_part=`echo $email | cut -d@ -f1` email_domain=`echo $email | cut -d@ -f2` curl --data "username=${mail_username}&password=${mail_password}&login=Log+In&rememberme=0" -c /tmp/cookie.txt https://${mail_hostname}/auth/login + +if ! curl -b /tmp/cookie.txt https://${mail_hostname}/domain | grep $email_domain | grep purge-domain | grep -o 'purge-domain-[0-9]*' | grep -o '[0-9]*' ; then + curl --data "backupmx=0&active=1&max_aliases=0&max_mailboxes=0&max_quota=0"a=0&transport=virtual&domain=${email_domain}" -b /tmp/cookie.txt https://${mail_hostname}/domain/add +fi + domain_id=`curl -b /tmp/cookie.txt https://${mail_hostname}/domain | grep $email_domain | grep purge-domain | grep -o 'purge-domain-[0-9]*' | grep -o '[0-9]*'` curl --data "local_part=${local_part}&domain=${domain_id}&password=${password}&welcome_email=1&cc_welcome_email=${cc_welcome_email}" -b /tmp/cookie.txt https://${mail_hostname}/mailbox/add -- GitLab