Commit cb6d7e51 authored by Marin Jankovski's avatar Marin Jankovski

Rescue an error if group doesn't exist

parent 7bf8d22f
...@@ -479,11 +479,13 @@ namespace :gitlab do ...@@ -479,11 +479,13 @@ namespace :gitlab do
return return
end end
if File.stat(repo_base_path).uid == uid_for(gitlab_shell_ssh_user) && uid = uid_for(gitlab_shell_ssh_user)
File.stat(repo_base_path).gid == gid_for(gitlab_shell_owner_group) gid = gid_for(gitlab_shell_owner_group)
if File.stat(repo_base_path).uid == uid && File.stat(repo_base_path).gid == gid
puts "yes".green puts "yes".green
else else
puts "no".red puts "no".red
puts " User id for #{gitlab_shell_ssh_user}: #{uid}. Groupd id for #{gitlab_shell_owner_group}: #{gid}".blue
try_fixing_it( try_fixing_it(
"sudo chown -R #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group} #{repo_base_path}" "sudo chown -R #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group} #{repo_base_path}"
) )
......
...@@ -80,7 +80,11 @@ namespace :gitlab do ...@@ -80,7 +80,11 @@ namespace :gitlab do
end end
def gid_for(group_name) def gid_for(group_name)
begin
Etc.getgrnam(group_name).gid Etc.getgrnam(group_name).gid
rescue ArgumentError # no group
"group #{group_name} doesn't exist"
end
end end
def warn_user_is_not_gitlab def warn_user_is_not_gitlab
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment