diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 62a510f2acc216ce5d12cf3eb64ec9b3d9447a79..c5e3d049fd77319bb0d545b7b34014948d5d7d4a 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -71,7 +71,7 @@ module Backup print 'Put GitLab hooks in repositories dirs'.yellow gitlab_shell_user_home = File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") - if system("#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh") + if system("#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh #{Gitlab.config.gitlab_shell.repos_path}") puts " [DONE]".green else puts " [FAILED]".red diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index 65d99d1aea3ea29067c79ad8d4320174f42055f6..d071938acb5193387ea7d6198c6c2bbbe7d1177e 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -90,13 +90,21 @@ namespace :gitlab do settings = YAML.load_file("backup_information.yml") ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0 - # restoring mismatching backups can lead to unexpected problems - if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/,"") - puts "GitLab version mismatch:".red - puts " Your current HEAD differs from the HEAD in the backup!".red - puts " Please switch to the following revision and try again:".red - puts " revision: #{settings[:gitlab_version]}".red - exit 1 + # backups directory is not always sub of Rails root and able to execute the git rev-parse below + begin + Dir.chdir(Rails.root) + + # restoring mismatching backups can lead to unexpected problems + if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/, "") + puts "GitLab version mismatch:".red + puts " Your current HEAD differs from the HEAD in the backup!".red + puts " Please switch to the following revision and try again:".red + puts " revision: #{settings[:gitlab_version]}".red + exit 1 + end + ensure + # chdir back to original intended dir + Dir.chdir(Gitlab.config.backup.path) end Rake::Task["gitlab:backup:db:restore"].invoke diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index ec5451dd47c5d13ecf9835c0ee092018d7fc6b23..11d4eacaa6957e1b525da29712159db79ae82fd4 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -26,10 +26,12 @@ namespace :gitlab do warn_user_is_not_gitlab gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys') - puts "This will rebuild an authorized_keys file." - puts "You will lose any data stored in #{gitlab_shell_authorized_keys}." - ask_to_continue - puts "" + unless ENV['force'] == 'yes' + puts "This will rebuild an authorized_keys file." + puts "You will lose any data stored in #{gitlab_shell_authorized_keys}." + ask_to_continue + puts "" + end system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}")