From 17f89ac648da9e27bd4e33ae8db428f9b03957da Mon Sep 17 00:00:00 2001 From: pierreozoux <pierre@ozoux.net> Date: Fri, 3 Jun 2016 11:24:12 +0200 Subject: [PATCH] script user adding --- utils/add_user | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 utils/add_user diff --git a/utils/add_user b/utils/add_user new file mode 100755 index 0000000..97aa94d --- /dev/null +++ b/utils/add_user @@ -0,0 +1,20 @@ +#!/bin/bash -eux + +source /etc/environment + +email=$1 +cc_welcome_email=$2 + +password=`tr -dc A-Za-z0-9_ < /dev/urandom | head -c 10 | xargs` +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 +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 + +rm /tmp/cookie.txt + +docker exec -it --user www-data `echo ${cloud_hostname}_app_1 |sed 's/-//g' | sed 's/\.//g'` bash -c "\ + OC_PASS=${password} php occ user:add --display-name ${local_part} ${local_part} --password-from-env &&\ + php occ mail:account:create ${local_part} ${local_part} ${email} ${mail_hostname} 993 ssl ${email} ${password} ${mail_hostname} 587 tls ${email} ${password}" -- GitLab