git.rake revision f6fd701c750b47c6c58a23b784d5b890317340a2
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornbergernamespace :git do
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger def reconfigure_cp_keys(source_file)
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger data_root = Ontohub::Application.config.data_root
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger git_home = Ontohub::Application.config.git_home
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger reconfigured_source = File.read(source_file).
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger sub(/^#define DATA_ROOT .*$/, "#define DATA_ROOT \"#{data_root}\"").
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger sub(/^#define GIT_HOME .*$/, "#define GIT_HOME \"#{git_home}\"")
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger reconfigured_source_file = Tempfile.new(%w(cp_keys .c))
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger reconfigured_source_file.write(reconfigured_source)
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger puts "Copying #{source_file} to tempfile #{reconfigured_source_file.path}"
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger puts "Reconfiguring DATA_ROOT in this tempfile to #{data_root}"
816bf6f8088b162b681101d93fd450127a0e586fJulian Kornberger puts "Reconfiguring GIT_HOME in this tempfile to #{git_home}"
puts "Compiling #{target_path.split('/').last} with"
puts "You need to manually set the owner/group of '#{path}' to #{owner_group}"
target_path = Rails.root.join('bin', 'cp_keys').to_s
compile_gcc(reconfigured_source_tempfile.path, target_path)
SSH_DIR = Ontohub::Application.config.data_root.join('.ssh')
AUTHORIZED_KEYS = SSH_DIR.join('authorized_keys')
if !File.exists?(AUTHORIZED_KEYS)
FileUtils.touch(AUTHORIZED_KEYS)
set_permissions('0640', AUTHORIZED_KEYS.to_s,