Commit 0236b3d17ead6a42e334e68b539fbc01cb348a6b
1 parent
fa203e8b
Exists in
master
and in
4 other branches
Rename status rake task to check
Showing
2 changed files
with
113 additions
and
113 deletions
Show diff stats
@@ -0,0 +1,113 @@ | @@ -0,0 +1,113 @@ | ||
1 | +namespace :gitlab do | ||
2 | + namespace :app do | ||
3 | + desc "GITLAB | Check GitLab installation status" | ||
4 | + task :status => :environment do | ||
5 | + puts "\nStarting diagnostics".yellow | ||
6 | + git_base_path = Gitlab.config.git_base_path | ||
7 | + | ||
8 | + print "config/database.yml............" | ||
9 | + if File.exists?(Rails.root.join "config", "database.yml") | ||
10 | + puts "exists".green | ||
11 | + else | ||
12 | + puts "missing".red | ||
13 | + return | ||
14 | + end | ||
15 | + | ||
16 | + print "config/gitlab.yml............" | ||
17 | + if File.exists?(Rails.root.join "config", "gitlab.yml") | ||
18 | + puts "exists".green | ||
19 | + else | ||
20 | + puts "missing".red | ||
21 | + return | ||
22 | + end | ||
23 | + | ||
24 | + print "#{git_base_path}............" | ||
25 | + if File.exists?(git_base_path) | ||
26 | + puts "exists".green | ||
27 | + else | ||
28 | + puts "missing".red | ||
29 | + return | ||
30 | + end | ||
31 | + | ||
32 | + print "#{git_base_path} is writable?............" | ||
33 | + if File.stat(git_base_path).writable? | ||
34 | + puts "YES".green | ||
35 | + else | ||
36 | + puts "NO".red | ||
37 | + return | ||
38 | + end | ||
39 | + | ||
40 | + FileUtils.rm_rf("/tmp/gitolite_gitlab_test") | ||
41 | + begin | ||
42 | + `git clone -q #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite_gitlab_test` | ||
43 | + raise unless $?.success? | ||
44 | + print "Can clone gitolite-admin?............" | ||
45 | + puts "YES".green | ||
46 | + rescue | ||
47 | + print "Can clone gitolite-admin?............" | ||
48 | + puts "NO".red | ||
49 | + return | ||
50 | + end | ||
51 | + | ||
52 | + begin | ||
53 | + Dir.chdir("/tmp/gitolite_gitlab_test") do | ||
54 | + `touch blah && git add blah && git commit -qm blah -- blah` | ||
55 | + raise unless $?.success? | ||
56 | + end | ||
57 | + print "Can git commit?............" | ||
58 | + puts "YES".green | ||
59 | + rescue | ||
60 | + print "Can git commit?............" | ||
61 | + puts "NO".red | ||
62 | + return | ||
63 | + ensure | ||
64 | + FileUtils.rm_rf("/tmp/gitolite_gitlab_test") | ||
65 | + end | ||
66 | + | ||
67 | + print "UMASK for .gitolite.rc is 0007? ............" | ||
68 | + if open(File.absolute_path("#{git_base_path}/../.gitolite.rc")).grep(/UMASK([ \t]*)=([ \t>]*)0007/).any? | ||
69 | + puts "YES".green | ||
70 | + else | ||
71 | + puts "NO".red | ||
72 | + return | ||
73 | + end | ||
74 | + | ||
75 | + gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") | ||
76 | + gitlab_hook_files = ['post-receive'] | ||
77 | + gitlab_hook_files.each do |file_name| | ||
78 | + dest = File.join(gitolite_hooks_path, file_name) | ||
79 | + print "#{dest} exists? ............" | ||
80 | + if File.exists?(dest) | ||
81 | + puts "YES".green | ||
82 | + else | ||
83 | + puts "NO".red | ||
84 | + return | ||
85 | + end | ||
86 | + end | ||
87 | + | ||
88 | + if Project.count > 0 | ||
89 | + puts "\nValidating projects repositories:".yellow | ||
90 | + Project.find_each(:batch_size => 100) do |project| | ||
91 | + print "* #{project.name}....." | ||
92 | + hook_file = File.join(project.path_to_repo, 'hooks', 'post-receive') | ||
93 | + | ||
94 | + unless File.exists?(hook_file) | ||
95 | + puts "post-receive file missing".red | ||
96 | + next | ||
97 | + end | ||
98 | + | ||
99 | + original_content = File.read(Rails.root.join('lib', 'hooks', 'post-receive')) | ||
100 | + new_content = File.read(hook_file) | ||
101 | + | ||
102 | + if original_content == new_content | ||
103 | + puts "post-receive file ok".green | ||
104 | + else | ||
105 | + puts "post-receive file content does not match".red | ||
106 | + end | ||
107 | + end | ||
108 | + end | ||
109 | + | ||
110 | + puts "\nFinished".blue | ||
111 | + end | ||
112 | + end | ||
113 | +end |
lib/tasks/gitlab/status.rake
@@ -1,113 +0,0 @@ | @@ -1,113 +0,0 @@ | ||
1 | -namespace :gitlab do | ||
2 | - namespace :app do | ||
3 | - desc "GITLAB | Check GitLab installation status" | ||
4 | - task :status => :environment do | ||
5 | - puts "\nStarting diagnostics".yellow | ||
6 | - git_base_path = Gitlab.config.git_base_path | ||
7 | - | ||
8 | - print "config/database.yml............" | ||
9 | - if File.exists?(Rails.root.join "config", "database.yml") | ||
10 | - puts "exists".green | ||
11 | - else | ||
12 | - puts "missing".red | ||
13 | - return | ||
14 | - end | ||
15 | - | ||
16 | - print "config/gitlab.yml............" | ||
17 | - if File.exists?(Rails.root.join "config", "gitlab.yml") | ||
18 | - puts "exists".green | ||
19 | - else | ||
20 | - puts "missing".red | ||
21 | - return | ||
22 | - end | ||
23 | - | ||
24 | - print "#{git_base_path}............" | ||
25 | - if File.exists?(git_base_path) | ||
26 | - puts "exists".green | ||
27 | - else | ||
28 | - puts "missing".red | ||
29 | - return | ||
30 | - end | ||
31 | - | ||
32 | - print "#{git_base_path} is writable?............" | ||
33 | - if File.stat(git_base_path).writable? | ||
34 | - puts "YES".green | ||
35 | - else | ||
36 | - puts "NO".red | ||
37 | - return | ||
38 | - end | ||
39 | - | ||
40 | - FileUtils.rm_rf("/tmp/gitolite_gitlab_test") | ||
41 | - begin | ||
42 | - `git clone -q #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite_gitlab_test` | ||
43 | - raise unless $?.success? | ||
44 | - print "Can clone gitolite-admin?............" | ||
45 | - puts "YES".green | ||
46 | - rescue | ||
47 | - print "Can clone gitolite-admin?............" | ||
48 | - puts "NO".red | ||
49 | - return | ||
50 | - end | ||
51 | - | ||
52 | - begin | ||
53 | - Dir.chdir("/tmp/gitolite_gitlab_test") do | ||
54 | - `touch blah && git add blah && git commit -qm blah -- blah` | ||
55 | - raise unless $?.success? | ||
56 | - end | ||
57 | - print "Can git commit?............" | ||
58 | - puts "YES".green | ||
59 | - rescue | ||
60 | - print "Can git commit?............" | ||
61 | - puts "NO".red | ||
62 | - return | ||
63 | - ensure | ||
64 | - FileUtils.rm_rf("/tmp/gitolite_gitlab_test") | ||
65 | - end | ||
66 | - | ||
67 | - print "UMASK for .gitolite.rc is 0007? ............" | ||
68 | - if open(File.absolute_path("#{git_base_path}/../.gitolite.rc")).grep(/UMASK([ \t]*)=([ \t>]*)0007/).any? | ||
69 | - puts "YES".green | ||
70 | - else | ||
71 | - puts "NO".red | ||
72 | - return | ||
73 | - end | ||
74 | - | ||
75 | - gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") | ||
76 | - gitlab_hook_files = ['post-receive'] | ||
77 | - gitlab_hook_files.each do |file_name| | ||
78 | - dest = File.join(gitolite_hooks_path, file_name) | ||
79 | - print "#{dest} exists? ............" | ||
80 | - if File.exists?(dest) | ||
81 | - puts "YES".green | ||
82 | - else | ||
83 | - puts "NO".red | ||
84 | - return | ||
85 | - end | ||
86 | - end | ||
87 | - | ||
88 | - if Project.count > 0 | ||
89 | - puts "\nValidating projects repositories:".yellow | ||
90 | - Project.find_each(:batch_size => 100) do |project| | ||
91 | - print "* #{project.name}....." | ||
92 | - hook_file = File.join(project.path_to_repo, 'hooks', 'post-receive') | ||
93 | - | ||
94 | - unless File.exists?(hook_file) | ||
95 | - puts "post-receive file missing".red | ||
96 | - next | ||
97 | - end | ||
98 | - | ||
99 | - original_content = File.read(Rails.root.join('lib', 'hooks', 'post-receive')) | ||
100 | - new_content = File.read(hook_file) | ||
101 | - | ||
102 | - if original_content == new_content | ||
103 | - puts "post-receive file ok".green | ||
104 | - else | ||
105 | - puts "post-receive file content does not match".red | ||
106 | - end | ||
107 | - end | ||
108 | - end | ||
109 | - | ||
110 | - puts "\nFinished".blue | ||
111 | - end | ||
112 | - end | ||
113 | -end |