Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
123af785
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
123af785
编写于
8月 20, 2015
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add gitlab:reply_by_email:check rake task.
上级
48e25a01
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
157 addition
and
3 deletion
+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
未找到文件。
doc/reply_by_email/README.md
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录