summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2014-07-04 09:22:54 +0100
committerMichael Drake <michael.drake@codethink.co.uk>2014-07-04 09:22:54 +0100
commitbe5669c7e6fff570c3db56ebc545b1244c443874 (patch)
tree0a29006b98dae0f4b9686e1adc37acbdc83e1494
parentb55c8552a68bf045199e8ca77849b7c6fd279ca7 (diff)
downloaddefinitions-be5669c7e6fff570c3db56ebc545b1244c443874.tar.gz
Allow SMTP details to be configured.baserock/michaeldrake/gitlab-smtp-config
This lets us configure a gitlab system to send e-mail at deploy time. It uses the following environment variables: * MAIL_SEND_TYPE * SMTP_ADDR * SMTP_PORT * SMTP_USER * SMTP_PASS * SMTP_DOMAIN
-rw-r--r--gitlab.configure30
1 files changed, 30 insertions, 0 deletions
diff --git a/gitlab.configure b/gitlab.configure
index ab4ef561..1ca2664a 100644
--- a/gitlab.configure
+++ b/gitlab.configure
@@ -25,6 +25,12 @@
# * UNICORN_PORT
# * CI_PORT
# * UNICORN_CI_PORT
+# * MAIL_SEND_TYPE
+# * SMTP_ADDR
+# * SMTP_PORT
+# * SMTP_USER
+# * SMTP_PASS
+# * SMTP_DOMAIN
set -e
@@ -82,3 +88,27 @@ EOF
ln -s "/etc/systemd/system/gitlab-setup.service" \
"$ROOT/etc/systemd/system/multi-user.target.wants/gitlab-setup.service"
+
+##########################################################################
+
+cat <<EOF > "$ROOT"/etc/gitlab-smtp-setup.sed
+s/"email.server.com"/"$SMTP_ADDR"/g
+s/"456"/"$SMTP_PORT"/g
+s/"smtp"/"$SMTP_USER"/g
+s/"123456"/"$SMTP_PASS"/g
+s/"gitlab.company.com"/"$SMTP_DOMAIN"/g
+EOF
+
+if [ "$MAIL_SEND_TYPE" = "smtp" ]; then
+
+ echo "Setting up SMPT for sending e-mail"
+
+ CONFIG_PATH="/usr/share/gitlab-ce/config"
+
+ sed -i 's/sendmail/smtp/' \
+ "$ROOT""$CONFIG_PATH"/environments/production.rb
+
+ sed -f "$ROOT"/etc/gitlab-smtp-setup.sed \
+ <"$ROOT""$CONFIG_PATH"/initializers/smtp_settings.rb.sample \
+ >"$ROOT""$CONFIG_PATH"/initializers/smtp_settings.rb
+fi