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
Léo-Paul Géneau
gitlab-ce
Commits
71000b39
Commit
71000b39
authored
Sep 04, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Incoming Email checks to use SystemCheck library
parent
eb79e568
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
117 deletions
+151
-117
lib/system_check/incoming_email/foreman_configured_check.rb
lib/system_check/incoming_email/foreman_configured_check.rb
+23
-0
lib/system_check/incoming_email/imap_authentication_check.rb
lib/system_check/incoming_email/imap_authentication_check.rb
+45
-0
lib/system_check/incoming_email/initd_configured_check.rb
lib/system_check/incoming_email/initd_configured_check.rb
+32
-0
lib/system_check/incoming_email/mail_room_running_check.rb
lib/system_check/incoming_email/mail_room_running_check.rb
+43
-0
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+8
-117
No files found.
lib/system_check/incoming_email/foreman_configured_check.rb
0 → 100644
View file @
71000b39
module
SystemCheck
module
IncomingEmail
class
ForemanConfiguredCheck
<
SystemCheck
::
BaseCheck
set_name
'Foreman configured correctly?'
def
check?
path
=
Rails
.
root
.
join
(
'Procfile'
)
File
.
exist?
(
path
)
&&
File
.
read
(
path
)
=~
/^mail_room:/
end
def
show_error
try_fixing_it
(
'Enable mail_room in your Procfile.'
)
for_more_information
(
'doc/administration/reply_by_email.md'
)
fix_and_rerun
end
end
end
end
lib/system_check/incoming_email/imap_authentication_check.rb
0 → 100644
View file @
71000b39
module
SystemCheck
module
IncomingEmail
class
ImapAuthenticationCheck
<
SystemCheck
::
BaseCheck
set_name
'IMAP server credentials are correct?'
def
check?
if
mailbox_config
begin
imap
=
Net
::
IMAP
.
new
(
config
[
:host
],
port:
config
[
:port
],
ssl:
config
[
:ssl
])
imap
.
starttls
if
config
[
:start_tls
]
imap
.
login
(
config
[
:email
],
config
[
:password
])
connected
=
true
rescue
connected
=
false
end
end
connected
end
def
show_error
try_fixing_it
(
'Check that the information in config/gitlab.yml is correct'
)
for_more_information
(
'doc/administration/reply_by_email.md'
)
fix_and_rerun
end
private
def
mailbox_config
return
@config
if
@config
config_path
=
Rails
.
root
.
join
(
'config'
,
'mail_room.yml'
).
to_s
erb
=
ERB
.
new
(
File
.
read
(
config_path
))
erb
.
filename
=
config_path
config_file
=
YAML
.
load
(
erb
.
result
)
@config
=
config_file
[
:mailboxes
]
&
.
first
end
end
end
end
lib/system_check/incoming_email/initd_configured_check.rb
0 → 100644
View file @
71000b39
module
SystemCheck
module
IncomingEmail
class
InitdConfiguredCheck
<
SystemCheck
::
BaseCheck
set_name
'Init.d configured correctly?'
def
skip?
omnibus_gitlab?
end
def
check?
mail_room_configured?
end
def
show_error
try_fixing_it
(
'Enable mail_room in the init.d configuration.'
)
for_more_information
(
'doc/administration/reply_by_email.md'
)
fix_and_rerun
end
private
def
mail_room_configured?
path
=
'/etc/default/gitlab'
File
.
exist?
(
path
)
&&
File
.
read
(
path
).
include?
(
'mail_room_enabled=true'
)
end
end
end
end
lib/system_check/incoming_email/mail_room_running_check.rb
0 → 100644
View file @
71000b39
module
SystemCheck
module
IncomingEmail
class
MailRoomRunningCheck
<
SystemCheck
::
BaseCheck
set_name
'MailRoom running?'
def
skip?
return
true
if
omnibus_gitlab?
unless
mail_room_configured?
self
.
skip_reason
=
"can't check because of previous errors"
true
end
end
def
check?
mail_room_running?
end
def
show_error
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
private
def
mail_room_configured?
path
=
'/etc/default/gitlab'
File
.
exist?
(
path
)
&&
File
.
read
(
path
).
include?
(
'mail_room_enabled=true'
)
end
def
mail_room_running?
ps_ux
,
_
=
Gitlab
::
Popen
.
popen
(
%w(ps uxww)
)
ps_ux
.
include?
(
"mail_room"
)
end
end
end
end
lib/tasks/gitlab/check.rake
View file @
71000b39
...
...
@@ -308,132 +308,23 @@ namespace :gitlab 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
.
incoming_email
.
enabled
check_imap_authentication
checks
=
[
SystemCheck
::
IncomingEmail
::
ImapAuthenticationCheck
]
if
Rails
.
env
.
production?
check_initd_configured_correctly
check_mail_room_running
else
check_foreman_configured_correctly
end
else
puts
'Reply by email is disabled in config/gitlab.yml'
end
finished_checking
"Reply by email"
end
# Checks
########################
def
check_initd_configured_correctly
return
if
omnibus_gitlab?
print
"Init.d configured correctly? ... "
path
=
"/etc/default/gitlab"
if
File
.
exist?
(
path
)
&&
File
.
read
(
path
).
include?
(
"mail_room_enabled=true"
)
puts
"yes"
.
color
(
:green
)
else
puts
"no"
.
color
(
:red
)
try_fixing_it
(
"Enable mail_room in the init.d configuration."
)
for_more_information
(
"doc/administration/reply_by_email.md"
)
fix_and_rerun
end
end
def
check_foreman_configured_correctly
print
"Foreman configured correctly? ... "
path
=
Rails
.
root
.
join
(
"Procfile"
)
if
File
.
exist?
(
path
)
&&
File
.
read
(
path
)
=~
/^mail_room:/
puts
"yes"
.
color
(
:green
)
else
puts
"no"
.
color
(
:red
)
try_fixing_it
(
"Enable mail_room in your Procfile."
)
for_more_information
(
"doc/administration/reply_by_email.md"
)
fix_and_rerun
end
end
def
check_mail_room_running
return
if
omnibus_gitlab?
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"
.
color
(
:magenta
)
return
end
if
mail_room_running?
puts
"yes"
.
color
(
:green
)
checks
<<
SystemCheck
::
IncomingEmail
::
InitdConfiguredCheck
checks
<<
SystemCheck
::
IncomingEmail
::
MailRoomRunningCheck
else
puts
"no"
.
color
(
: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
checks
<<
SystemCheck
::
IncomingEmail
::
ForemanConfiguredCheck
end
def
check_imap_authentication
print
"IMAP server credentials are correct? ... "
config_path
=
Rails
.
root
.
join
(
'config'
,
'mail_room.yml'
).
to_s
erb
=
ERB
.
new
(
File
.
read
(
config_path
))
erb
.
filename
=
config_path
config_file
=
YAML
.
load
(
erb
.
result
)
config
=
config_file
[
:mailboxes
].
first
if
config
begin
imap
=
Net
::
IMAP
.
new
(
config
[
:host
],
port:
config
[
:port
],
ssl:
config
[
:ssl
])
imap
.
starttls
if
config
[
:start_tls
]
imap
.
login
(
config
[
:email
],
config
[
:password
])
connected
=
true
rescue
connected
=
false
end
end
if
connected
puts
"yes"
.
color
(
:green
)
SystemCheck
.
run
(
'Reply by email'
,
checks
)
else
puts
"no"
.
color
(
:red
)
try_fixing_it
(
"Check that the information in config/gitlab.yml is correct"
)
for_more_information
(
"doc/administration/reply_by_email.md"
)
fix_and_rerun
end
puts
'Reply by email is disabled in config/gitlab.yml'
end
def
mail_room_running?
ps_ux
,
_
=
Gitlab
::
Popen
.
popen
(
%w(ps uxww)
)
ps_ux
.
include?
(
"mail_room"
)
end
end
...
...
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