compose-website/utils/add_email.sh

28 lines
711 B
Bash
Raw Normal View History

2015-03-05 17:32:05 +00:00
#!/bin/bash -ex
2015-04-03 08:40:42 +00:00
EMAIL=$1
2015-03-05 17:32:05 +00:00
PASSWORD=`echo $RANDOM date | md5sum | base64 | cut -c-10`
MYSQL_PASS=`cat /data/domains/mail/mysql/.env | cut -d= -f2`
2015-04-03 08:40:42 +00:00
DOMAIN=$(echo ${EMAIL} | cut -f2 -d@)
2015-03-05 17:32:05 +00:00
/usr/bin/docker run \
--rm \
--name add_email_support_to_$DOMAIN \
--link mysql-mail:db \
2015-04-03 08:40:42 +00:00
indiepaas/mysql \
2015-03-05 17:32:05 +00:00
mysql \
-uadmin \
-p$MYSQL_PASS \
-h db \
-e "INSERT INTO servermail.virtual_users (domain_id, password , email) \
VALUES( \
(SELECT id FROM servermail.virtual_domains WHERE name='$DOMAIN'), \
ENCRYPT('$PASSWORD', CONCAT('\$6\$', SUBSTRING(SHA(RAND()), -16))), \
2015-04-03 08:40:42 +00:00
'$EMAIL');"
echo "Email added with success"
echo "Pass: $PASSWORD"
2015-03-05 17:32:05 +00:00