Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login shell #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ sudo = true # default false
cache_dirs = ['public/cache', 'tmp/cache'] # default ['public/cache']
skip_steps = ['install_gems', 'clear_cache'] # default []
app_folder = 'project_folder' # default empty
login_shell = true # default false
</code></pre>

h2. SKIP STEPS
Expand Down
2 changes: 1 addition & 1 deletion lib/inploy/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Deploy
include DSL

attr_accessor :repository, :user, :application, :hosts, :path, :app_folder, :ssh_opts, :branch, :environment,
:port, :skip_steps, :cache_dirs, :sudo
:port, :skip_steps, :cache_dirs, :sudo, :login_shell

define_callbacks :after_setup, :before_restarting_server

Expand Down
6 changes: 5 additions & 1 deletion lib/inploy/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ def run(command, disable_sudo = false)
def remote_run(command)
port_opts = port ? "-p #{port} " : ''
hosts.each do |host|
run "ssh #{ssh_opts} #{port_opts}#{user}@#{host} '#{command}'", true
run "ssh #{ssh_opts} #{port_opts}#{user}@#{host} #{login_shell_wrap(command)}", true
end
end

def login_shell_wrap(cmd)
login_shell ? "\"sh -l -c '#{cmd}'\"" : "'#{cmd}'"
end

def secure_copy(src, dest)
unless file_exists?(dest)
log "mv #{src} #{dest}"
Expand Down
1 change: 1 addition & 0 deletions spec/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def setup(subject)
subject.ssh_opts = @ssh_opts = "-A"
subject.branch = @branch = "onions"
subject.environment = @environment = "staging"
subject.login_shell = @login_shell = false
end

context "on remote setup" do
Expand Down
6 changes: 6 additions & 0 deletions spec/shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
subject.remote_update
end

it "should run inploy:local:update task with login_shell" do
subject.login_shell = true
expect_command "ssh #{@ssh_opts} #{@user}@#{@host} \"sh -l -c 'cd #{@path}/#{@application} && rake inploy:local:update environment=#{subject.environment}'\""
subject.remote_update
end

it "should ssh with a port even if ssh options are not specified" do
subject.ssh_opts = nil
subject.port = 3892
Expand Down