diff --git a/README.textile b/README.textile index 80dd353..cedd0a9 100644 --- a/README.textile +++ b/README.textile @@ -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 h2. SKIP STEPS diff --git a/lib/inploy/deploy.rb b/lib/inploy/deploy.rb index 999e023..30a6862 100644 --- a/lib/inploy/deploy.rb +++ b/lib/inploy/deploy.rb @@ -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 diff --git a/lib/inploy/dsl.rb b/lib/inploy/dsl.rb index 02deee2..49ad27c 100644 --- a/lib/inploy/dsl.rb +++ b/lib/inploy/dsl.rb @@ -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}" diff --git a/spec/deploy_spec.rb b/spec/deploy_spec.rb index bfc0421..afddd78 100644 --- a/spec/deploy_spec.rb +++ b/spec/deploy_spec.rb @@ -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 diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb index 7803c2c..c4654da 100644 --- a/spec/shared_examples.rb +++ b/spec/shared_examples.rb @@ -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