1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#!/usr/bin/env ruby
$:.unshift File.expand_path('../lib', __FILE__)
require 'gitlab_init'
#
# GitLab shell, invoked from ~/.ssh/authorized_keys
#
config = GitlabConfig.new
key_dir = File.dirname("#{config.auth_file}")
repository_storage_paths = ARGV
commands = [
%W(mkdir -p #{key_dir}),
%W(chmod 700 #{key_dir}),
]
repository_storage_paths.each do |repository_storage_path|
commands << %W(mkdir -p #{repository_storage_path})
commands << %W(chmod ug+rwX,o-rwx #{repository_storage_path})
end
commands.each do |cmd|
print "#{cmd.join(' ')}: "
if system(*cmd)
puts 'OK'
else
puts 'Failed'
abort "#{$PROGRAM_NAME} failed"
end
end
exit
|