diff options
-rw-r--r-- | gitlab.configure | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gitlab.configure b/gitlab.configure index ab4ef561..9798c775 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,41 @@ EOF ln -s "/etc/systemd/system/gitlab-setup.service" \ "$ROOT/etc/systemd/system/multi-user.target.wants/gitlab-setup.service" + +########################################################################## + +rubyescape() { + # In ruby, single quoted strings need \ and ' escaping + printf "%s\n" "$1" | sed -e "s/['\\]/\\\&/g" \ + -e "s/^/'/" \ + -e "s/$/'/" +} + +sedescape() { + # Escape all non-alphanumeric characters + printf "%s\n" "$1" | sed -e 's/\W/\\&/g' +} + +do_escapes() { + printf "%s\n" "$(sedescape "$(rubyescape "$1")")" +} + +if [ "$MAIL_SEND_TYPE" = "smtp" ]; then + + echo "Setting up SMTP for sending e-mail" + + for CONFIG_PATH in \ + "/usr/share/gitlab-ce/config" "/usr/share/gitlab-ci/config" + do + sed -i 's/sendmail/smtp/' \ + "$ROOT$CONFIG_PATH/environments/production.rb" + + sed -e s/\"email.server.com\"/"$(do_escapes "$SMTP_ADDR")/g" \ + -e s/\"smtp\"/"$(do_escapes "$SMTP_USER")/g" \ + -e s/\"123456\"/"$(do_escapes "$SMTP_PASS")/g" \ + -e s/\"gitlab.company.com\"/"$(do_escapes "$SMTP_DOMAIN")/g" \ + -e s/456/$SMTP_PORT/g \ + <"$ROOT$CONFIG_PATH/initializers/smtp_settings.rb.sample" \ + >"$ROOT$CONFIG_PATH/initializers/smtp_settings.rb" + done +fi |