Merge branch 'reply_by_email_config' into 'master'

Reply by email support

Closes #732

See merge request !447
This commit is contained in:
Marin Jankovski 2015-08-26 15:26:40 +00:00
commit 3181425e05
11 changed files with 142 additions and 0 deletions

View File

@ -32,6 +32,19 @@ external_url 'GENERATED_EXTERNAL_URL'
# gitlab_rails['gravatar_ssl_url'] = 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
# gitlab_rails['webhook_timeout'] = 10
## Reply by email
# You need access to IMAP-enabled email account. For details
# see http://doc.gitlab.com/ce/reply_by_email/README.html
# gitlab_rails['reply_by_email_enabled'] = true
# gitlab_rails['reply_by_email_address'] = "replies+%{reply_key}@gitlab.example.com"
# gitlab_rails['reply_by_email_host'] = "imap.gmail.com" # IMAP server host
# gitlab_rails['reply_by_email_port'] = 993 # IMAP server port
# gitlab_rails['reply_by_email_ssl'] = true # Whether the IMAP server uses SSL
# gitlab_rails['reply_by_email_email'] = "replies@gitlab.example.com" # Email account username. Usually the full email address.
# gitlab_rails['reply_by_email_password'] = "password" # Email account password
# gitlab_rails['reply_by_email_mailbox_name'] = "inbox" # The name of the mailbox where incoming mail will end up.
# gitlab_rails['reply_by_email_log_directory'] = "/var/log/gitlab/mailroom"
## For setting up LDAP
## see https://gitlab.com/gitlab-org/omnibus-gitlab/blob/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#setting-up-ldap-sign-in
## Be careful not to break the identation in the ldap_servers block. It is in

View File

@ -84,6 +84,13 @@ default['gitlab']['gitlab-rails']['gitlab_default_projects_features_visibility_l
default['gitlab']['gitlab-rails']['gitlab_repository_downloads_path'] = nil
default['gitlab']['gitlab-rails']['gravatar_plain_url'] = nil
default['gitlab']['gitlab-rails']['gravatar_ssl_url'] = nil
default['gitlab']['gitlab-rails']['reply_by_email_enabled'] = false
default['gitlab']['gitlab-rails']['reply_by_email_address'] = nil
default['gitlab']['gitlab-rails']['reply_by_email_host'] = nil
default['gitlab']['gitlab-rails']['reply_by_email_port'] = nil
default['gitlab']['gitlab-rails']['reply_by_email_ssl'] = nil
default['gitlab']['gitlab-rails']['reply_by_email_email'] = nil
default['gitlab']['gitlab-rails']['reply_by_email_log_directory'] = "/var/log/gitlab/mailroom"
default['gitlab']['gitlab-rails']['ldap_enabled'] = false
default['gitlab']['gitlab-rails']['ldap_servers'] = []

View File

@ -0,0 +1,48 @@
#
# Copyright:: Copyright (c) 2014 GitLab B.V.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
define :mailroom_service, :rails_app => nil, :user => nil do
svc = params[:name]
user = params[:user]
rails_app = params[:rails_app]
mailroom_log_dir = node['gitlab']['gitlab-rails']['reply_by_email_log_directory']
mail_room_config = File.join(node['gitlab']['gitlab-rails']['dir'], "etc", "mail_room.yml")
directory mailroom_log_dir do
owner user
mode '0700'
recursive true
end
runit_service svc do
template_name 'mailroom'
options({
:rails_app => rails_app,
:user => user,
:log_directory => mailroom_log_dir,
:mail_room_config => mail_room_config
}.merge(params))
log_options node['gitlab']['logging'].to_hash
end
if node['gitlab']['bootstrap']['enable']
execute "/opt/gitlab/bin/gitlab-ctl start #{svc}" do
retries 20
end
end
end

View File

@ -168,6 +168,21 @@ template_symlink File.join(gitlab_rails_etc_dir, "rack_attack.rb") do
restarts dependent_services
end
template_symlink File.join(gitlab_rails_etc_dir, "mail_room.yml") do
link_from File.join(gitlab_rails_source_dir, "config/mail_room.yml")
source "mail_room.yml.erb"
owner "root"
group "root"
mode "0644"
variables(
node['gitlab']['gitlab-rails'].to_hash.merge(
:redis_url => redis_url
)
)
restarts dependent_services
action node['gitlab']['gitlab-rails']['reply_by_email_enabled'] ? :create : :delete
end
link File.join(gitlab_rails_source_dir, ".gitlab_shell_secret") do
to File.join(gitlab_shell_source_dir, ".gitlab_shell_secret")
end

View File

@ -20,3 +20,10 @@ sidekiq_service 'sidekiq' do
rails_app 'gitlab-rails'
user node['gitlab']['user']['username']
end
if node['gitlab']['gitlab-rails']['reply_by_email_enabled']
mailroom_service 'mailroom' do
rails_app 'gitlab-rails'
user node['gitlab']['user']['username']
end
end

View File

@ -78,6 +78,13 @@ production: &base
# The default is 'tmp/repositories' relative to the root of the Rails app.
repository_downloads_path: <%= @gitlab_repository_downloads_path %>
## Reply by email
# Allow users to comment on issues and merge requests by replying to notification emails.
# For documentation on how to set this up, see http://doc.gitlab.com/ce/reply_by_email/README.md
reply_by_email:
enabled: <%= @reply_by_email_enabled %>
address: <%= @reply_by_email_address %>
## Gravatar
## For Libravatar see: http://doc.gitlab.com/ce/customization/libravatar.html
gravatar:

View File

@ -0,0 +1,26 @@
:mailboxes:
-
# IMAP server host
:host: <%= @reply_by_email_host %>
# IMAP server port
:port: <%= @reply_by_email_port %>
# Whether the IMAP server uses SSL
:ssl: <%= @reply_by_email_ssl %>
# Email account username. Usually the full email address.
:email: <%= @reply_by_email_email %>
# Email account password
:password: <%= @reply_by_email_password %>
# The name of the mailbox where incoming mail will end up. Usually "inbox".
:name: <%= @reply_by_email_mailbox_name %>
# Always "sidekiq".
:delivery_method: sidekiq
:delete_after_delivery: true
:delivery_options:
# The URL to the Redis server used by Sidekiq. Should match the URL in config/resque.yml.
:redis_url: <%= @redis_url %>
# Always "resque:gitlab".
:namespace: resque:gitlab
# Always "incoming_email".
:queue: incoming_email
# Always "EmailReceiverWorker"
:worker: EmailReceiverWorker

View File

@ -0,0 +1,6 @@
<%= "s#@svlogd_size" if @svlogd_size %>
<%= "n#@svlogd_num" if @svlogd_num %>
<%= "t#@svlogd_timeout" if @svlogd_timeout %>
<%= "!#@svlogd_filter" if @svlogd_filter %>
<%= "u#@svlogd_udp" if @svlogd_udp %>
<%= "p#@svlogd_prefix" if @svlogd_prefix %>

View File

@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd -tt <%= @options[:log_directory] %>

View File

@ -0,0 +1,10 @@
#!/bin/sh
cd <%= node['gitlab'][@options[:rails_app]]['dir'] %>/working
exec 2>&1
exec chpst -e /opt/gitlab/etc/<%= @options[:rails_app] %>/env -P \
-U <%= @options[:user] %> -u <%= @options[:user] %> \
/opt/gitlab/embedded/bin/bundle exec mail_room \
-q -c <%= @options[:mail_room_config] %>

View File

@ -13,6 +13,7 @@ exec chpst -e /opt/gitlab/etc/<%= @options[:rails_app] %>/env -P \
-q system_hook \
-q project_web_hook \
-q gitlab_shell \
-q incoming_email \
-q common \
-q default \
-e <%= node['gitlab'][@options[:rails_app]]['environment'] %> \