tasks/mina/default.rb in mina-1.0.0.beta1 vs tasks/mina/default.rb in mina-1.0.0.beta2
- old
+ new
@@ -13,10 +13,23 @@
puts "#{key.inspect} => #{value.inspect}"
end
end
end
+desc 'Adds current repo host to the known hosts'
+task :ssh_keyscan do
+ ensure!(:repository)
+ repo_host = fetch(:repository).split(%r{@|://}).last.split(%r{:|\/}).first
+ repo_port = /:([0-9]+)/.match(fetch(:repository)) && /:([0-9]+)/.match(fetch(:repository))[1] || '22'
+
+ command %[
+ if ! ssh-keygen -H -F #{repo_host} &>/dev/null; then
+ ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
+ fi
+ ]
+end
+
desc 'Runs a command in the server.'
task :run, [:command] => [:environment] do |_, args|
ensure!(:deploy_to)
command = args[:command]
@@ -30,7 +43,7 @@
end
end
desc 'Open an ssh session to the server and cd to deploy_to folder'
task ssh: :environment do
- exec ssh_command + " 'cd #{deploy_to} && exec \$SHELL'"
+ exec Mina::Backend::Remote.new(nil).ssh + " 'cd #{fetch(:deploy_to)} && exec \$SHELL'"
end