From f3c3d808922258323275e74a60c9a3a23fab1856 Mon Sep 17 00:00:00 2001 From: margarida Date: Sun, 29 Nov 2020 00:41:07 +0000 Subject: [PATCH] [TOOLS][DOCKER] Add mail setup to configure --- bin/configure | 68 +++++++++++++++++++++++++++++++++--- docker/mail/config/aliases | 0 docker/mail/config/domains | 0 docker/mail/config/mailboxes | 0 docker/mail/config/passwd | 0 docker/mail/setup.sh | 41 +++++++++------------- docker/social/mail | 1 + 7 files changed, 80 insertions(+), 30 deletions(-) create mode 100644 docker/mail/config/aliases create mode 100644 docker/mail/config/domains create mode 100644 docker/mail/config/mailboxes create mode 100644 docker/mail/config/passwd mode change 100644 => 100755 docker/mail/setup.sh diff --git a/bin/configure b/bin/configure index 6a98ba212c..e6eff28ca4 100755 --- a/bin/configure +++ b/bin/configure @@ -85,7 +85,7 @@ fi mkdir -p $ROOT/docker/bootstrap -cat > ./docker/bootstrap/bootstrap.env < $ROOT/docker/bootstrap/bootstrap.env <&- check_input $db_root_password - cat > ./docker/db/db.env < $ROOT/docker/db/db.env < ./docker/db/db.env < $ROOT/docker/db/db.env <> .env.local mkdir -p $ROOT/docker/social -cat > ./docker/social/social.env < $ROOT/docker/social/social.env <&1 + mail_domain_root=$(dialog \ + --title "Configure Mail" \ + --clear \ + --ok-label "Ok" \ + --cancel-label "Exit" \ + --inputbox "E-mail domain root:" $HEIGHT $WIDTH \ + 2>&1 1>&3) + check_retval $? + exec 3>&- + check_input $mail_domain_root + + exec 3>&1 + mail_subdomain=$(dialog \ + --title "Configure Mail" \ + --clear \ + --ok-label "Ok" \ + --cancel-label "Exit" \ + --inputbox "E-mail subdomain (can be empty):" $HEIGHT $WIDTH \ + 2>&1 1>&3) + check_retval $? + exec 3>&- + + exec 3>&1 + mail_user=$(dialog \ + --title "Configure Mail" \ + --clear \ + --ok-label "Ok" \ + --cancel-label "Exit" \ + --inputbox "E-mail user (name without @domain): " $HEIGHT $WIDTH \ + 2>&1 1>&3) + check_retval $? + exec 3>&- + check_input $mail_user + + exec 3>&1 + mail_pass=$(dialog \ + --title "Configure Mail" \ + --clear \ + --ok-label "Ok" \ + --cancel-label "Exit" \ + --inputbox "E-mail user password: " $HEIGHT $WIDTH \ + 2>&1 1>&3) + check_retval $? + exec 3>&- + check_input $mail_pass + + mkdir -p $ROOT/docker/mail + + cat > $ROOT/docker/mail/mail.env <> docker-compose.yaml -clear + diff --git a/docker/mail/config/aliases b/docker/mail/config/aliases new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docker/mail/config/domains b/docker/mail/config/domains new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docker/mail/config/mailboxes b/docker/mail/config/mailboxes new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docker/mail/config/passwd b/docker/mail/config/passwd new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docker/mail/setup.sh b/docker/mail/setup.sh old mode 100644 new mode 100755 index 9df2646137..199feb16f4 --- a/docker/mail/setup.sh +++ b/docker/mail/setup.sh @@ -1,39 +1,30 @@ #!/bin/sh + +ROOT="$(git rev-parse --show-toplevel)" +. $ROOT/docker/mail/mail.env + cd "${0%/*}" -printf "Domain root: " -read -r domain_root -printf "Subdomain (can be empty): " -read -r sub_domain - -printf "E-mail user (name without @domain): " -read -r user -printf "E-mail pass: " -read -r pass - -if [ -z "${sub_domain}" ] +if [ -z "${MAIL_SUBDOMAIN}" ] then - domain="${domain_root}" + domain="${MAIL_DOMAIN_ROOT}" else - domain="${sub_domain}.${domain_root}" + domain="${MAIL_SUBDOMAIN}.${MAIL_DOMAIN_ROOT}" fi +PASSHASH=$(mkpasswd -m sha-512 -S "" -R 5000 ${MAIL_PASSWORD}) + cat > mail.env < config/domains echo "${USER} ${USER}" > config/aliases -echo "${USER} ${DOMAINNAME}/${user}/" > config/mailboxes +echo "${USER} ${DOMAINNAME}/${MAIL_USER}/" > config/mailboxes echo "${USER}:${PASSHASH}" > config/passwd diff --git a/docker/social/mail b/docker/social/mail index 9633cdebd8..0fdbe7c815 100755 --- a/docker/social/mail +++ b/docker/social/mail @@ -6,6 +6,7 @@ echo " mail: - ./docker/mail/mail.env ports: - 25:25 + - 110:110 - 143:143 - 587:587 - 993:993