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
Jérome Perrin
gitlab-ce
Commits
57e210f6
Commit
57e210f6
authored
Dec 13, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2266 from riyad/improve-status-checks
Improve status checks
parents
fa203e8b
fe608f30
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1055 additions
and
137 deletions
+1055
-137
doc/install/installation.md
doc/install/installation.md
+14
-6
doc/raketasks/maintenance.md
doc/raketasks/maintenance.md
+73
-17
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+959
-0
lib/tasks/gitlab/info.rake
lib/tasks/gitlab/info.rake
+9
-1
lib/tasks/gitlab/status.rake
lib/tasks/gitlab/status.rake
+0
-113
No files found.
doc/install/installation.md
View file @
57e210f6
...
@@ -52,14 +52,14 @@ edited by hand. But, you can use any editor you like instead.
...
@@ -52,14 +52,14 @@ edited by hand. But, you can use any editor you like instead.
Install the required packages:
Install the required packages:
sudo apt-get install -y
wget curl build-essential checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev zlib1g-dev libicu-dev redis-server openssh-server git-core libyaml-dev postfix
sudo apt-get install -y
build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev wget curl git-core openssh-server redis-server postfix checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev
Make sure you have the right version of Python installed.
Make sure you have the right version of Python installed.
# Install Python
# Install Python
sudo apt-get install python
sudo apt-get install python
# Make sure that Python is 2.
x
(3.x is not supported at the moment)
# Make sure that Python is 2.
5+
(3.x is not supported at the moment)
python --version
python --version
# If it's Python 3 you might need to install Python 2 separately
# If it's Python 3 you might need to install Python 2 separately
...
@@ -136,10 +136,10 @@ GitLab assumes *full and unshared* control over this Gitolite installation.
...
@@ -136,10 +136,10 @@ GitLab assumes *full and unshared* control over this Gitolite installation.
# ... and use it as the admin key for the Gitolite setup
# ... and use it as the admin key for the Gitolite setup
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
Fix the directory permissions for the repositor
y
:
Fix the directory permissions for the repositor
ies
:
# Make sure the repositories dir is owned by git and it stays that way
# Make sure the repositories dir is owned by git and it stays that way
sudo chmod -R ug+rwXs /home/git/repositories/
sudo chmod -R ug+rwXs
,o-rwx
/home/git/repositories/
sudo chown -R git:git /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
## Test if everything works so far
## Test if everything works so far
...
@@ -187,6 +187,12 @@ do so with caution!
...
@@ -187,6 +187,12 @@ do so with caution!
# host serving GitLab where necessary
# host serving GitLab where necessary
sudo -u gitlab -H vim config/gitlab.yml
sudo -u gitlab -H vim config/gitlab.yml
# Make sure GitLab can write to the log/ and tmp/ directories
sudo chown -R gitlab log/
sudo chown -R gitlab tmp/
sudo chmod -R u+rwX log/
sudo chmod -R u+rwX tmp/
# Copy the example Unicorn config
# Copy the example Unicorn config
sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb
...
@@ -209,7 +215,7 @@ used for the `email.from` setting in `config/gitlab.yml`)
...
@@ -209,7 +215,7 @@ used for the `email.from` setting in `config/gitlab.yml`)
sudo -u gitlab -H git config --global user.name "GitLab"
sudo -u gitlab -H git config --global user.name "GitLab"
sudo -u gitlab -H git config --global user.email "gitlab@localhost"
sudo -u gitlab -H git config --global user.email "gitlab@localhost"
## Setup GitLab
h
ooks
## Setup GitLab
H
ooks
sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
...
@@ -227,7 +233,7 @@ Check if GitLab and its environment is configured correctly:
...
@@ -227,7 +233,7 @@ Check if GitLab and its environment is configured correctly:
To make sure you didn't miss anything run a more thorough check with:
To make sure you didn't miss anything run a more thorough check with:
sudo -u gitlab -H bundle exec rake gitlab:
app:status
RAILS_ENV=production
sudo -u gitlab -H bundle exec rake gitlab:
check
RAILS_ENV=production
If you are all green: congratulations, you successfully installed GitLab!
If you are all green: congratulations, you successfully installed GitLab!
Although this is the case, there are still a few steps to go.
Although this is the case, there are still a few steps to go.
...
@@ -248,6 +254,8 @@ Make GitLab start on boot:
...
@@ -248,6 +254,8 @@ Make GitLab start on boot:
Start your GitLab instance:
Start your GitLab instance:
sudo service gitlab start
sudo service gitlab start
# or
sudo /etc/init.d/gitlab restart
# 7. Nginx
# 7. Nginx
...
...
doc/raketasks/maintenance.md
View file @
57e210f6
...
@@ -54,9 +54,18 @@ Git: /usr/bin/git
...
@@ -54,9 +54,18 @@ Git: /usr/bin/git
```
```
### Check GitLab
installation status
### Check GitLab
configuration
[
Trouble-Shooting-Guide
](
https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide
)
Runs the following rake tasks:
*
gitlab:env:check
*
gitlab:gitolite:check
*
gitlab:resque:check
*
gitlab:app:check
It will check that each component was setup according to the installation guide and suggest fixes for issues found.
You may also have a look at our
[
Trouble Shooting Guide
](
https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide
)
.
```
```
bundle exec rake gitlab:check
bundle exec rake gitlab:check
...
@@ -65,21 +74,68 @@ bundle exec rake gitlab:check
...
@@ -65,21 +74,68 @@ bundle exec rake gitlab:check
Example output:
Example output:
```
```
config/database.yml............exists
Checking Environment ...
config/gitlab.yml............exists
/home/git/repositories/............exists
gitlab user is in git group? ... yes
/home/git/repositories/ is writable?............YES
Has no "-e" in ~git/.profile ... yes
Can clone gitolite-admin?............YES
Git configured for gitlab user? ... yes
Can git commit?............YES
Has python2? ... yes
UMASK for .gitolite.rc is 0007? ............YES
python2 is supported version? ... yes
/home/git/.gitolite/hooks/common/post-receive exists? ............YES
Checking Environment ... Finished
Validating projects repositories:
* abcd.....post-receive file ok
Checking Gitolite ...
* abcdtest.....post-receive file missing
Using recommended version ... yes
Finished
Repo umask is 0007 in .gitolite.rc? ... yes
Allow all Git config keys in .gitolite.rc ... yes
Config directory exists? ... yes
Config directory owned by git:git? ... yes
Config directory access is drwxr-x---? ... yes
Repo base directory exists? ... yes
Repo base owned by git:git? ... yes
Repo base access is drwsrws---? ... yes
Can clone gitolite-admin? ... yes
Can commit to gitolite-admin? ... yes
post-receive hook exists? ... yes
post-receive hook up-to-date? ... yes
post-receive hooks in repos are links: ...
GitLab ... ok
Non-Ascii Files Test ... ok
Touch Commit Test ... ok
Without Master Test ... ok
Git config in repos: ...
GitLab ... ok
Non-Ascii Files Test ... ok
Touch Commit Test ... ok
Without Master Test ... ok
Checking Gitolite ... Finished
Checking Resque ...
Running? ... yes
Checking Resque ... Finished
Checking GitLab ...
Database config exists? ... yes
Database is not SQLite ... yes
All migrations up? ... yes
GitLab config exists? ... yes
GitLab config not outdated? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... yes
Projects have satellites? ...
GitLab ... yes
Non-Ascii Files Test ... yes
Touch Commit Test ... yes
Without Master Test ... yes
Checking GitLab ... Finished
```
```
...
...
lib/tasks/gitlab/check.rake
0 → 100644
View file @
57e210f6
namespace
:gitlab
do
desc
"GITLAB | Check the configuration of GitLab and its environment"
task
check:
%w{gitlab:env:check
gitlab:gitolite:check
gitlab:resque:check
gitlab:app:check}
namespace
:app
do
desc
"GITLAB | Check the configuration of the GitLab Rails app"
task
check: :environment
do
warn_user_is_not_gitlab
start_checking
"GitLab"
check_database_config_exists
check_database_is_not_sqlite
check_migrations_are_up
check_gitlab_config_exists
check_gitlab_config_not_outdated
check_log_writable
check_tmp_writable
check_init_script_exists
check_init_script_up_to_date
check_satellites_exist
finished_checking
"GitLab"
end
# Checks
########################
def
check_database_config_exists
print
"Database config exists? ... "
database_config_file
=
Rails
.
root
.
join
(
"config"
,
"database.yml"
)
if
File
.
exists?
(
database_config_file
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Copy config/database.yml.<your db> to config/database.yml"
,
"Check that the information in config/database.yml is correct"
)
for_more_information
(
see_database_guide
,
"http://guides.rubyonrails.org/getting_started.html#configuring-a-database"
)
check_failed
end
end
def
check_database_is_not_sqlite
print
"Database is not SQLite ... "
database_config_file
=
Rails
.
root
.
join
(
"config"
,
"database.yml"
)
unless
File
.
read
(
database_config_file
)
=~
/sqlite/
puts
"yes"
.
green
else
puts
"no"
.
red
for_more_information
(
"https://github.com/gitlabhq/gitlabhq/wiki/Migrate-from-SQLite-to-MySQL"
,
see_database_guide
)
check_failed
end
end
def
check_gitlab_config_exists
print
"GitLab config exists? ... "
gitlab_config_file
=
Rails
.
root
.
join
(
"config"
,
"gitlab.yml"
)
if
File
.
exists?
(
gitlab_config_file
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Copy config/gitlab.yml.example to config/gitlab.yml"
,
"Update config/gitlab.yml to match your setup"
)
for_more_information
(
see_installation_guide_section
"GitLab"
)
check_failed
end
end
def
check_gitlab_config_not_outdated
print
"GitLab config not outdated? ... "
gitlab_config_file
=
Rails
.
root
.
join
(
"config"
,
"gitlab.yml"
)
unless
File
.
exists?
(
gitlab_config_file
)
puts
"can't check because of previous errors"
.
magenta
end
# omniauth or ldap could have been deleted from the file
if
File
.
read
(
gitlab_config_file
)
=~
/^web:/
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Copy config/gitlab.yml.example to config/gitlab.yml"
,
"Update config/gitlab.yml to match your setup"
)
for_more_information
(
see_installation_guide_section
"GitLab"
)
check_failed
end
end
def
check_init_script_exists
print
"Init script exists? ... "
script_path
=
"/etc/init.d/gitlab"
if
File
.
exists?
(
script_path
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Install the init script"
)
for_more_information
(
see_installation_guide_section
"Install Init Script"
)
check_failed
end
end
def
check_init_script_up_to_date
print
"Init script up-to-date? ... "
script_path
=
"/etc/init.d/gitlab"
unless
File
.
exists?
(
script_path
)
puts
"can't check because of previous errors"
.
magenta
return
end
recipe_content
=
`curl https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab 2>/dev/null`
script_content
=
File
.
read
(
script_path
)
if
recipe_content
==
script_content
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Redownload the init script"
)
for_more_information
(
see_installation_guide_section
"Install Init Script"
)
check_failed
end
end
def
check_migrations_are_up
print
"All migrations up? ... "
migration_status
=
`bundle exec rake db:migrate:status`
unless
migration_status
=~
/down\s+\d{14}/
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo -u gitlab -H bundle exec rake db:migrate"
)
check_failed
end
end
def
check_satellites_exist
print
"Projects have satellites? ... "
unless
Project
.
count
>
0
puts
"can't check, you have no projects"
.
magenta
return
end
puts
""
Project
.
find_each
(
batch_size:
100
)
do
|
project
|
print
"
#{
project
.
name
.
yellow
}
... "
if
project
.
satellite
.
exists?
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo -u gitlab -H bundle exec rake gitlab:app:enable_automerge"
)
for_more_information
(
"doc/raketasks/maintenance.md "
)
check_failed
end
end
end
def
check_log_writable
print
"Log directory writable? ... "
log_path
=
Rails
.
root
.
join
(
"log"
)
if
File
.
writable?
(
log_path
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo chown -R gitlab
#{
log_path
}
"
,
"sudo chmod -R rwX
#{
log_path
}
"
)
for_more_information
(
see_installation_guide_section
"GitLab"
)
check_failed
end
end
def
check_tmp_writable
print
"Tmp directory writable? ... "
tmp_path
=
Rails
.
root
.
join
(
"tmp"
)
if
File
.
writable?
(
tmp_path
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo chown -R gitlab
#{
tmp_path
}
"
,
"sudo chmod -R rwX
#{
tmp_path
}
"
)
for_more_information
(
see_installation_guide_section
"GitLab"
)
check_failed
end
end
end
namespace
:env
do
desc
"GITLAB | Check the configuration of the environment"
task
check: :environment
do
warn_user_is_not_gitlab
start_checking
"Environment"
check_gitlab_in_git_group
check_issue_1056_shell_profile_error
check_gitlab_git_config
check_python2_exists
check_python2_version
finished_checking
"Environment"
end
# Checks
########################
def
check_gitlab_git_config
print
"Git configured for gitlab user? ... "
options
=
{
"user.name"
=>
"GitLab"
,
"user.email"
=>
Gitlab
.
config
.
email_from
}
correct_options
=
options
.
map
do
|
name
,
value
|
run
(
"git config --global --get
#{
name
}
"
).
try
(
:squish
)
==
value
end
if
correct_options
.
all?
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo -u gitlab -H git config --global user.name
\"
#{
options
[
"user.name"
]
}
\"
"
,
"sudo -u gitlab -H git config --global user.email
\"
#{
options
[
"user.email"
]
}
\"
"
)
for_more_information
(
see_installation_guide_section
"GitLab"
)
check_failed
end
end
def
check_gitlab_in_git_group
print
"gitlab user is in git group? ... "
if
run_and_match
(
"id -rnG"
,
/\Wgit\W/
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo usermod -a -G git gitlab"
)
for_more_information
(
see_installation_guide_section
"System Users"
)
check_failed
end
end
# see https://github.com/gitlabhq/gitlabhq/issues/1059
def
check_issue_1056_shell_profile_error
print
"Has no
\"
-e
\"
in ~git/.profile ... "
profile_file
=
File
.
expand_path
(
"~
#{
Gitlab
.
config
.
ssh_user
}
/.profile"
)
unless
File
.
read
(
profile_file
)
=~
/^-e PATH/
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Open
#{
profile_file
}
"
,
"Find the line starting with
\"
-e PATH
\"
"
,
"Remove
\"
-e
\"
so the line starts with PATH"
)
for_more_information
(
see_installation_guide_section
(
"Gitolite"
),
"https://github.com/gitlabhq/gitlabhq/issues/1059"
)
check_failed
end
end
def
check_python2_exists
print
"Has python2? ... "
# Python prints its version to STDERR
# so we can't just use run("python2 --version")
if
run_and_match
(
"which python2"
,
/python2$/
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Make sure you have Python 2.5+ installed"
,
"Link it to python2"
)
for_more_information
(
see_installation_guide_section
"Packages / Dependencies"
)
check_failed
end
end
def
check_python2_version
print
"python2 is supported version? ... "
# Python prints its version to STDERR
# so we can't just use run("python2 --version")
unless
run_and_match
(
"which python2"
,
/python2$/
)
puts
"can't check because of previous errors"
.
magenta
return
end
if
`python2 --version 2>&1`
=~
/2\.[567]\.\d/
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Make sure you have Python 2.5+ installed"
,
"Link it to python2"
)
for_more_information
(
see_installation_guide_section
"Packages / Dependencies"
)
check_failed
end
end
end
namespace
:gitolite
do
desc
"GITLAB | Check the configuration of Gitolite"
task
check: :environment
do
warn_user_is_not_gitlab
start_checking
"Gitolite"
check_gitolite_is_up_to_date
check_gitoliterc_repo_umask
check_gitoliterc_git_config_keys
check_dot_gitolite_exists
check_dot_gitolite_user_and_group
check_dot_gitolite_permissions
check_repo_base_exists
check_repo_base_user_and_group
check_repo_base_permissions
check_can_clone_gitolite_admin
check_can_commit_to_gitolite_admin
check_post_receive_hook_exists
check_post_receive_hook_is_up_to_date
check_repos_post_receive_hooks_is_link
check_repos_git_config
finished_checking
"Gitolite"
end
# Checks
########################
def
check_can_clone_gitolite_admin
print
"Can clone gitolite-admin? ... "
test_path
=
"/tmp/gitlab_gitolite_admin_test"
FileUtils
.
rm_rf
(
test_path
)
`git clone -q
#{
Gitlab
.
config
.
gitolite_admin_uri
}
#{
test_path
}
`
raise
unless
$?
.
success?
puts
"yes"
.
green
rescue
puts
"no"
.
red
try_fixing_it
(
"Make sure the
\"
admin_uri
\"
is set correctly in config/gitlab.yml"
,
"Try cloning it yourself with:"
,
" git clone -q
#{
Gitlab
.
config
.
gitolite_admin_uri
}
/tmp/gitolite-admin"
,
"Make sure Gitolite is installed correctly."
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
# assumes #check_can_clone_gitolite_admin has been run before
def
check_can_commit_to_gitolite_admin
print
"Can commit to gitolite-admin? ... "
test_path
=
"/tmp/gitlab_gitolite_admin_test"
unless
File
.
exists?
(
test_path
)
puts
"can't check because of previous errors"
.
magenta
return
end
Dir
.
chdir
(
test_path
)
do
`touch foo && git add foo && git commit -qm foo`
raise
unless
$?
.
success?
end
puts
"yes"
.
green
rescue
puts
"no"
.
red
try_fixing_it
(
"Try committing to it yourself with:"
,
" git clone -q
#{
Gitlab
.
config
.
gitolite_admin_uri
}
/tmp/gitolite-admin"
,
" touch foo"
,
" git add foo"
,
" git commit -m
\"
foo
\"
"
,
"Make sure Gitolite is installed correctly."
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
ensure
FileUtils
.
rm_rf
(
"/tmp/gitolite_gitlab_test"
)
end
def
check_dot_gitolite_exists
print
"Config directory exists? ... "
gitolite_config_path
=
File
.
expand_path
(
"~
#{
Gitlab
.
config
.
ssh_user
}
/.gitolite"
)
if
File
.
directory?
(
gitolite_config_path
)
puts
"yes"
.
green
else
puts
"no"
.
red
puts
"
#{
gitolite_config_path
}
is missing"
.
red
try_fixing_it
(
"This should have been created when setting up Gitolite."
,
"Make sure Gitolite is installed correctly."
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
end
def
check_dot_gitolite_permissions
print
"Config directory access is drwxr-x---? ... "
gitolite_config_path
=
File
.
expand_path
(
"~
#{
Gitlab
.
config
.
ssh_user
}
/.gitolite"
)
unless
File
.
exists?
(
gitolite_config_path
)
puts
"can't check because of previous errors"
.
magenta
return
end
if
`stat --printf %a
#{
gitolite_config_path
}
`
==
"750"
puts
"yes"
.
green
else
puts
"no"
.
red
puts
"
#{
gitolite_config_path
}
is not writable"
.
red
try_fixing_it
(
"sudo chmod 750
#{
gitolite_config_path
}
"
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
end
def
check_dot_gitolite_user_and_group
print
"Config directory owned by git:git? ... "
gitolite_config_path
=
File
.
expand_path
(
"~
#{
Gitlab
.
config
.
ssh_user
}
/.gitolite"
)
unless
File
.
exists?
(
gitolite_config_path
)
puts
"can't check because of previous errors"
.
magenta
return
end
if
`stat --printf %U
#{
gitolite_config_path
}
`
==
"git"
&&
# user
`stat --printf %G
#{
gitolite_config_path
}
`
==
"git"
#group
puts
"yes"
.
green
else
puts
"no"
.
red
puts
"
#{
gitolite_config_path
}
is not owned by git"
.
red
try_fixing_it
(
"sudo chown -R git:git
#{
gitolite_config_path
}
"
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
end
def
check_gitolite_is_up_to_date
print
"Using recommended version ... "
if
gitolite_version
.
try
(
:start_with?
,
"v3.04"
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"We strongly recommend using the version pointed out in the installation guide."
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
# this is not a "hard" failure
end
end
def
check_gitoliterc_git_config_keys
gitoliterc_path
=
File
.
join
(
gitolite_home
,
".gitolite.rc"
)
print
"Allow all Git config keys in .gitolite.rc ... "
option_name
=
if
has_gitolite3?
# see https://github.com/sitaramc/gitolite/blob/v3.04/src/lib/Gitolite/Rc.pm#L329
"GIT_CONFIG_KEYS"
else
# assume older version
# see https://github.com/sitaramc/gitolite/blob/v2.3/conf/example.gitolite.rc#L49
"$GL_GITCONFIG_KEYS"
end
option_value
=
".*"
if
open
(
gitoliterc_path
).
grep
(
/
#{
option_name
}
\s*=[>]?\s*["']
#{
option_value
}
["']/
).
any?
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Open
#{
gitoliterc_path
}
"
,
"Find the
\"
#{
option_name
}
\"
option"
,
"Change its value to
\"
.*
\"
"
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
end
def
check_gitoliterc_repo_umask
gitoliterc_path
=
File
.
join
(
gitolite_home
,
".gitolite.rc"
)
print
"Repo umask is 0007 in .gitolite.rc? ... "
option_name
=
if
has_gitolite3?
# see https://github.com/sitaramc/gitolite/blob/v3.04/src/lib/Gitolite/Rc.pm#L328
"UMASK"
else
# assume older version
# see https://github.com/sitaramc/gitolite/blob/v2.3/conf/example.gitolite.rc#L32
"$REPO_UMASK"
end
option_value
=
"0007"
if
open
(
gitoliterc_path
).
grep
(
/
#{
option_name
}
\s*=[>]?\s*
#{
option_value
}
/
).
any?
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"Open
#{
gitoliterc_path
}
"
,
"Find the
\"
#{
option_name
}
\"
option"
,
"Change its value to
\"
0007
\"
"
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
end
def
check_post_receive_hook_exists
print
"post-receive hook exists? ... "
hook_file
=
"post-receive"
gitolite_hooks_path
=
File
.
join
(
Gitlab
.
config
.
git_hooks_path
,
"common"
)
gitolite_hook_file
=
File
.
join
(
gitolite_hooks_path
,
hook_file
)
gitlab_hook_file
=
Rails
.
root
.
join
.
join
(
"lib"
,
"hooks"
,
hook_file
)
if
File
.
exists?
(
gitolite_hook_file
)
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo -u git cp
#{
gitlab_hook_file
}
#{
gitolite_hook_file
}
"
)
for_more_information
(
see_installation_guide_section
"Setup GitLab Hooks"
)
check_failed
end
end
def
check_post_receive_hook_is_up_to_date
print
"post-receive hook up-to-date? ... "
hook_file
=
"post-receive"
gitolite_hooks_path
=
File
.
join
(
Gitlab
.
config
.
git_hooks_path
,
"common"
)
gitolite_hook_file
=
File
.
join
(
gitolite_hooks_path
,
hook_file
)
gitolite_hook_content
=
File
.
read
(
gitolite_hook_file
)
unless
File
.
exists?
(
gitolite_hook_file
)
puts
"can't check because of previous errors"
.
magenta
return
end
gitlab_hook_file
=
Rails
.
root
.
join
.
join
(
"lib"
,
"hooks"
,
hook_file
)
gitlab_hook_content
=
File
.
read
(
gitlab_hook_file
)
if
gitolite_hook_content
==
gitlab_hook_content
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo -u git cp
#{
gitlab_hook_file
}
#{
gitolite_hook_file
}
"
)
for_more_information
(
see_installation_guide_section
"Setup GitLab Hooks"
)
check_failed
end
end
def
check_repo_base_exists
print
"Repo base directory exists? ... "
repo_base_path
=
Gitlab
.
config
.
git_base_path
if
File
.
exists?
(
repo_base_path
)
puts
"yes"
.
green
else
puts
"no"
.
red
puts
"
#{
repo_base_path
}
is missing"
.
red
try_fixing_it
(
"This should have been created when setting up Gitolite."
,
"Make sure it's set correctly in config/gitlab.yml"
,
"Make sure Gitolite is installed correctly."
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
end
def
check_repo_base_permissions
print
"Repo base access is drwsrws---? ... "
repo_base_path
=
Gitlab
.
config
.
git_base_path
unless
File
.
exists?
(
repo_base_path
)
puts
"can't check because of previous errors"
.
magenta
return
end
if
`stat --printf %a
#{
repo_base_path
}
`
==
"6770"
puts
"yes"
.
green
else
puts
"no"
.
red
puts
"
#{
repo_base_path
}
is not writable"
.
red
try_fixing_it
(
"sudo chmod -R ug+rwXs,o-rwx
#{
repo_base_path
}
"
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
end
def
check_repo_base_user_and_group
print
"Repo base owned by git:git? ... "
repo_base_path
=
Gitlab
.
config
.
git_base_path
unless
File
.
exists?
(
repo_base_path
)
puts
"can't check because of previous errors"
.
magenta
return
end
if
`stat --printf %U
#{
repo_base_path
}
`
==
"git"
&&
# user
`stat --printf %G
#{
repo_base_path
}
`
==
"git"
#group
puts
"yes"
.
green
else
puts
"no"
.
red
puts
"
#{
repo_base_path
}
is not owned by git"
.
red
try_fixing_it
(
"sudo chown -R git:git
#{
repo_base_path
}
"
)
for_more_information
(
see_installation_guide_section
"Gitolite"
)
check_failed
end
end
def
check_repos_git_config
print
"Git config in repos: ... "
unless
Project
.
count
>
0
puts
"can't check, you have no projects"
.
magenta
return
end
puts
""
options
=
{
"core.sharedRepository"
=>
"0660"
,
}
Project
.
find_each
(
batch_size:
100
)
do
|
project
|
print
"
#{
project
.
name
.
yellow
}
... "
correct_options
=
options
.
map
do
|
name
,
value
|
run
(
"git --git-dir=
\"
#{
project
.
path_to_repo
}
\"
config --get
#{
name
}
"
).
try
(
:chomp
)
==
value
end
if
correct_options
.
all?
puts
"ok"
.
green
else
puts
"wrong or missing"
.
red
try_fixing_it
(
"sudo -u gitlab -H bundle exec rake gitlab:gitolite:update_repos"
)
for_more_information
(
"doc/raketasks/maintenance.md"
)
check_failed
end
end
end
def
check_repos_post_receive_hooks_is_link
print
"post-receive hooks in repos are links: ... "
hook_file
=
"post-receive"
gitolite_hooks_path
=
File
.
join
(
Gitlab
.
config
.
git_hooks_path
,
"common"
)
gitolite_hook_file
=
File
.
join
(
gitolite_hooks_path
,
hook_file
)
unless
File
.
exists?
(
gitolite_hook_file
)
puts
"can't check because of previous errors"
.
magenta
return
end
unless
Project
.
count
>
0
puts
"can't check, you have no projects"
.
magenta
return
end
puts
""
Project
.
find_each
(
batch_size:
100
)
do
|
project
|
print
"
#{
project
.
name
.
yellow
}
... "
project_hook_file
=
File
.
join
(
project
.
path_to_repo
,
"hooks"
,
hook_file
)
unless
File
.
exists?
(
project_hook_file
)
puts
"missing"
.
red
try_fixing_it
(
"sudo -u git ln -sf
#{
gitolite_hook_file
}
#{
project_hook_file
}
"
)
for_more_information
(
"lib/support/rewrite-hooks.sh"
)
check_failed
next
end
if
run_and_match
(
"stat --format %N
#{
project_hook_file
}
"
,
/
#{
hook_file
}
.+->.+
#{
gitolite_hook_file
}
/
)
puts
"ok"
.
green
else
puts
"not a link to Gitolite's hook"
.
red
try_fixing_it
(
"sudo -u git ln -sf
#{
gitolite_hook_file
}
#{
project_hook_file
}
"
)
for_more_information
(
"lib/support/rewrite-hooks.sh"
)
check_failed
end
end
end
# Helper methods
########################
def
gitolite_home
File
.
expand_path
(
"~
#{
Gitlab
.
config
.
ssh_user
}
"
)
end
def
gitolite_version
gitolite_version_file
=
"
#{
gitolite_home
}
/gitolite/src/VERSION"
if
File
.
readable?
(
gitolite_version_file
)
File
.
read
(
gitolite_version_file
)
end
end
def
has_gitolite3?
gitolite_version
.
try
(
:start_with?
,
"v3."
)
end
end
namespace
:resque
do
desc
"GITLAB | Check the configuration of Resque"
task
check: :environment
do
warn_user_is_not_gitlab
start_checking
"Resque"
check_resque_running
finished_checking
"Resque"
end
# Checks
########################
def
check_resque_running
print
"Running? ... "
if
run_and_match
(
"ps aux | grep -i resque"
,
/resque-[\d\.]+:.+$/
)
puts
"yes"
.
green
else
puts
"no"
.
red
puts
"
#{
repo_base_path
}
is not owned by git"
.
red
try_fixing_it
(
"sudo service gitlab restart"
,
"or"
,
"sudo /etc/init.d/gitlab restart"
)
for_more_information
(
see_installation_guide_section
(
"Install Init Script"
),
"see log/resque.log for possible errors"
)
check_failed
end
end
end
# Helper methods
##########################
def
check_failed
puts
" Please
#{
"fix the error above"
}
and rerun the checks."
.
red
end
def
for_more_information
(
*
sources
)
sources
=
sources
.
shift
if
sources
.
first
.
is_a?
(
Array
)
puts
" For more information see:"
.
blue
sources
.
each
do
|
source
|
puts
"
#{
source
}
"
end
end
def
finished_checking
(
component
)
puts
""
puts
"Checking
#{
component
.
yellow
}
...
#{
"Finished"
.
green
}
"
puts
""
end
# Runs the given command
#
# Returns nil if the command was not found
# Returns the output of the command otherwise
#
# see also #run_and_match
def
run
(
command
)
unless
`
#{
command
}
2>/dev/null`
.
blank?
`
#{
command
}
`
end
end
# Runs the given command and matches the output agains the given pattern
#
# Returns nil if nothing matched
# Retunrs the MatchData if the pattern matched
#
# see also #run
# see also String#match
def
run_and_match
(
command
,
pattern
)
run
(
command
).
try
(
:match
,
pattern
)
end
def
see_database_guide
"doc/install/databases.md"
end
def
see_installation_guide_section
(
section
)
"doc/install/installation.md in section
\"
#{
section
}
\"
"
end
def
start_checking
(
component
)
puts
"Checking
#{
component
.
yellow
}
..."
puts
""
end
def
try_fixing_it
(
*
steps
)
steps
=
steps
.
shift
if
steps
.
first
.
is_a?
(
Array
)
puts
" Try fixing it:"
.
blue
steps
.
each
do
|
step
|
puts
"
#{
step
}
"
end
end
def
warn_user_is_not_gitlab
unless
@warned_user_not_gitlab
current_user
=
run
(
"whoami"
).
chomp
unless
current_user
==
"gitlab"
puts
"
#{
Colored
.
color
(
:black
)
+
Colored
.
color
(
:on_yellow
)
}
Warning
#{
Colored
.
extra
(
:clear
)
}
"
puts
" You are running as user
#{
current_user
.
magenta
}
, we hope you know what you are doing."
puts
" Some tests may pass
\/
fail for the wrong reason."
puts
" For meaningful results you should run this as user
#{
"gitlab"
.
magenta
}
."
puts
""
end
@warned_user_not_gitlab
=
true
end
end
end
lib/tasks/gitlab/info.rake
View file @
57e210f6
...
@@ -84,7 +84,13 @@ namespace :gitlab do
...
@@ -84,7 +84,13 @@ namespace :gitlab do
# Helper methods
# Helper methods
# Runs the given command and matches the output agains the given RegExp
# Runs the given command and matches the output agains the given pattern
#
# Returns nil if nothing matched
# Retunrs the MatchData if the pattern matched
#
# see also #run
# see also String#match
def
run_and_match
(
command
,
regexp
)
def
run_and_match
(
command
,
regexp
)
run
(
command
).
try
(
:match
,
regexp
)
run
(
command
).
try
(
:match
,
regexp
)
end
end
...
@@ -93,6 +99,8 @@ namespace :gitlab do
...
@@ -93,6 +99,8 @@ namespace :gitlab do
#
#
# Returns nil if the command was not found
# Returns nil if the command was not found
# Returns the output of the command otherwise
# Returns the output of the command otherwise
#
# see also #run_and_match
def
run
(
command
)
def
run
(
command
)
unless
`
#{
command
}
2>/dev/null`
.
blank?
unless
`
#{
command
}
2>/dev/null`
.
blank?
`
#{
command
}
`
`
#{
command
}
`
...
...
lib/tasks/gitlab/status.rake
deleted
100644 → 0
View file @
fa203e8b
namespace
:gitlab
do
namespace
:app
do
desc
"GITLAB | Check GitLab installation status"
task
:status
=>
:environment
do
puts
"
\n
Starting diagnostics"
.
yellow
git_base_path
=
Gitlab
.
config
.
git_base_path
print
"config/database.yml............"
if
File
.
exists?
(
Rails
.
root
.
join
"config"
,
"database.yml"
)
puts
"exists"
.
green
else
puts
"missing"
.
red
return
end
print
"config/gitlab.yml............"
if
File
.
exists?
(
Rails
.
root
.
join
"config"
,
"gitlab.yml"
)
puts
"exists"
.
green
else
puts
"missing"
.
red
return
end
print
"
#{
git_base_path
}
............"
if
File
.
exists?
(
git_base_path
)
puts
"exists"
.
green
else
puts
"missing"
.
red
return
end
print
"
#{
git_base_path
}
is writable?............"
if
File
.
stat
(
git_base_path
).
writable?
puts
"YES"
.
green
else
puts
"NO"
.
red
return
end
FileUtils
.
rm_rf
(
"/tmp/gitolite_gitlab_test"
)
begin
`git clone -q
#{
Gitlab
.
config
.
gitolite_admin_uri
}
/tmp/gitolite_gitlab_test`
raise
unless
$?
.
success?
print
"Can clone gitolite-admin?............"
puts
"YES"
.
green
rescue
print
"Can clone gitolite-admin?............"
puts
"NO"
.
red
return
end
begin
Dir
.
chdir
(
"/tmp/gitolite_gitlab_test"
)
do
`touch blah && git add blah && git commit -qm blah -- blah`
raise
unless
$?
.
success?
end
print
"Can git commit?............"
puts
"YES"
.
green
rescue
print
"Can git commit?............"
puts
"NO"
.
red
return
ensure
FileUtils
.
rm_rf
(
"/tmp/gitolite_gitlab_test"
)
end
print
"UMASK for .gitolite.rc is 0007? ............"
if
open
(
File
.
absolute_path
(
"
#{
git_base_path
}
/../.gitolite.rc"
)).
grep
(
/UMASK([ \t]*)=([ \t>]*)0007/
).
any?
puts
"YES"
.
green
else
puts
"NO"
.
red
return
end
gitolite_hooks_path
=
File
.
join
(
Gitlab
.
config
.
git_hooks_path
,
"common"
)
gitlab_hook_files
=
[
'post-receive'
]
gitlab_hook_files
.
each
do
|
file_name
|
dest
=
File
.
join
(
gitolite_hooks_path
,
file_name
)
print
"
#{
dest
}
exists? ............"
if
File
.
exists?
(
dest
)
puts
"YES"
.
green
else
puts
"NO"
.
red
return
end
end
if
Project
.
count
>
0
puts
"
\n
Validating projects repositories:"
.
yellow
Project
.
find_each
(
:batch_size
=>
100
)
do
|
project
|
print
"*
#{
project
.
name
}
....."
hook_file
=
File
.
join
(
project
.
path_to_repo
,
'hooks'
,
'post-receive'
)
unless
File
.
exists?
(
hook_file
)
puts
"post-receive file missing"
.
red
next
end
original_content
=
File
.
read
(
Rails
.
root
.
join
(
'lib'
,
'hooks'
,
'post-receive'
))
new_content
=
File
.
read
(
hook_file
)
if
original_content
==
new_content
puts
"post-receive file ok"
.
green
else
puts
"post-receive file content does not match"
.
red
end
end
end
puts
"
\n
Finished"
.
blue
end
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