Sha256: 30d12887c9cbbc97971d80f36fbe3347656256a0250f3874133b7319d612a144

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

namespace :load do
  task :defaults do
    set :safe_deploy_to_owner, nil
    set :safe_deploy_to_path, -> { fetch(:deploy_to) }
  end
end

namespace :safe_deploy_to do
  task :create do
    on roles :all do
      sudo :mkdir, '-pv', fetch(:safe_deploy_to_path)
    end
  end

  task ensure_owner: [:create] do
    on roles :all do
      unless fetch(:safe_deploy_to_owner)
        user = capture :id, '-un'
        group = capture :id, '-gn'
        set :safe_deploy_to_owner, "#{user}:#{group}"
      end
      sudo :chown, fetch(:safe_deploy_to_owner), fetch(:safe_deploy_to_path)
    end
  end

  desc "Ensures deploy_to directory exists and has the right owner"
  task ensure: [:create, :ensure_owner]
end

before "deploy:check", "safe_deploy_to:ensure"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-safe-deploy-to-1.0.0 lib/capistrano/tasks/safe_deploy_to.rake