Skip to content
Snippets Groups Projects
Commit 17f89ac6 authored by Pierre Ozoux's avatar Pierre Ozoux
Browse files

script user adding

parent 4591a06a
No related branches found
No related tags found
No related merge requests found
#!/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}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment