Last active
August 29, 2015 13:56
-
-
Save dolzenko/8835793 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SSHKit::Backend::Netssh | |
alias_method :command_orig, :command | |
def command(*a) | |
@user = 'test2' # TODO replace with user to sudo to | |
command_orig(*a) | |
ensure | |
@user = nil | |
end | |
end | |
# Replace capistrano tasks | |
stages.each do |stage| | |
after stage, :hack do | |
Rake::Task[:'deploy:log_revision'].clear | |
namespace :deploy do | |
desc 'Log details of the deploy' | |
task :log_revision do | |
on release_roles(:all) do | |
within releases_path do | |
# HACK execute with string doesn't respect @user ? | |
# execute %{echo "#{revision_log_message}" >> #{revision_log}} | |
execute :echo, "'#{revision_log_message}' >> #{revision_log}" | |
end | |
end | |
end | |
end | |
Rake::Task[:'git:wrapper'].clear | |
namespace :git do | |
desc 'Upload the git wrapper script, this script guarantees that we can script git without getting an interactive prompt' | |
task :wrapper do | |
on release_roles :all do | |
execute :mkdir, "-p", "#{fetch(:tmp_dir)}/#{fetch(:application)}/" | |
# HACK upload doesn't respect @user | |
# (known issue, see https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md#upload-a-file-from-disk ) | |
# upload! StringIO.new("#!/bin/sh -e\nexec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"), "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh" | |
code = "#!/bin/sh -e\nexec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n" | |
execute :echo, "'#{code}' > #{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh" | |
execute :chmod, "+x", "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment