Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
123af785
Commit
123af785
authored
Aug 20, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add gitlab:reply_by_email:check rake task.
parent
48e25a01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
157 additions
and
3 deletions
+157
-3
doc/reply_by_email/README.md
doc/reply_by_email/README.md
+6
-0
lib/gitlab/reply_by_email.rb
lib/gitlab/reply_by_email.rb
+6
-3
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+145
-0
No files found.
doc/reply_by_email/README.md
View file @
123af785
...
...
@@ -93,6 +93,12 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`. If you'
sudo
service gitlab restart
```
7.
Check if everything is configured correctly
```sh
sudo bundle exec rake gitlab:reply_by_email:check RAILS_ENV=production
```
8.
Reply by email should now be working.
Note: If you're running GitLab in development mode and using
`foreman`
, make sure to also uncomment the
`mail_room`
line in your
`Procfile`
.
...
...
lib/gitlab/reply_by_email.rb
View file @
123af785
...
...
@@ -2,9 +2,12 @@ module Gitlab
module
ReplyByEmail
class
<<
self
def
enabled?
config
.
enabled
&&
config
.
address
&&
config
.
address
.
include?
(
"%{reply_key}"
)
config
.
enabled
&&
address_formatted_correctly?
end
def
address_formatted_correctly?
config
.
address
&&
config
.
address
.
include?
(
"%{reply_key}"
)
end
def
reply_key
...
...
lib/tasks/gitlab/check.rake
View file @
123af785
...
...
@@ -2,6 +2,7 @@ namespace :gitlab do
desc
"GitLab | Check the configuration of GitLab and its environment"
task
check:
%w{gitlab:gitlab_shell:check
gitlab:sidekiq:check
gitlab:reply_by_email:check
gitlab:ldap:check
gitlab:app:check}
...
...
@@ -577,6 +578,150 @@ namespace :gitlab do
end
end
namespace
:reply_by_email
do
desc
"GitLab | Check the configuration of Reply by email"
task
check: :environment
do
warn_user_is_not_gitlab
start_checking
"Reply by email"
if
Gitlab
.
config
.
reply_by_email
.
enabled
check_address_formatted_correctly
check_mail_room_config_exists
check_imap_authentication
check_initd_configured_correctly
check_mail_room_running
else
puts
'Reply by email is disabled in config/gitlab.yml'
end
finished_checking
"Reply by email"
end
# Checks
########################
def
check_address_formatted_correctly
print
"Address formatted correctly? ... "
if
Gitlab
::
ReplyByEmail
.
address_formatted_correctly?
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Make sure that the address in config/gitlab.yml includes the '%{reply_key}' placeholder."
)
fix_and_rerun
end
end
def
check_initd_configured_correctly
print
"Init.d configured correctly? ... "
path
=
"/etc/default/gitlab"
if
File
.
exist?
(
path
)
&&
File
.
read
(
path
).
include?
(
"mail_room_enabled=true"
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Enable mail_room in the init.d configuration."
)
for_more_information
(
"doc/reply_by_email/README.md"
)
fix_and_rerun
end
end
def
check_mail_room_running
print
"MailRoom running? ... "
path
=
"/etc/default/gitlab"
unless
File
.
exist?
(
path
)
&&
File
.
read
(
path
).
include?
(
"mail_room_enabled=true"
)
puts
"can't check because of previous errors"
.
magenta
return
end
if
mail_room_process_count
>
0
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
sudo_gitlab
(
"RAILS_ENV=production bin/mail_room start"
)
)
for_more_information
(
see_installation_guide_section
(
"Install Init Script"
),
"see log/mail_room.log for possible errors"
)
fix_and_rerun
end
end
def
check_mail_room_config_exists
print
"MailRoom config exists? ... "
mail_room_config_file
=
Rails
.
root
.
join
(
"config"
,
"mail_room.yml"
)
if
File
.
exists?
(
mail_room_config_file
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Copy config/mail_room.yml.example to config/mail_room.yml"
,
"Check that the information in config/mail_room.yml is correct"
)
for_more_information
(
"doc/reply_by_email/README.md"
)
fix_and_rerun
end
end
def
check_imap_authentication
print
"IMAP server credentials are correct? ... "
mail_room_config_file
=
Rails
.
root
.
join
(
"config"
,
"mail_room.yml"
)
unless
File
.
exists?
(
mail_room_config_file
)
puts
"can't check because of previous errors"
.
magenta
return
end
config
=
YAML
.
load_file
(
mail_room_config_file
)[
:mailboxes
].
first
rescue
nil
if
config
begin
imap
=
Net
::
IMAP
.
new
(
config
[
:host
],
port:
config
[
:port
],
ssl:
config
[
:ssl
])
imap
.
login
(
config
[
:email
],
config
[
:password
])
connected
=
true
rescue
connected
=
false
end
end
if
connected
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Check that the information in config/mail_room.yml is correct"
)
for_more_information
(
"doc/reply_by_email/README.md"
)
fix_and_rerun
end
end
def
mail_room_process_count
ps_ux
,
_
=
Gitlab
::
Popen
.
popen
(
%W(ps ux)
)
ps_ux
.
scan
(
/mail_room \d+\.\d+\.\d+/
).
count
end
end
namespace
:ldap
do
task
:check
,
[
:limit
]
=>
:environment
do
|
t
,
args
|
# Only show up to 100 results because LDAP directories can be very big.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment