Sha256: d37e5cc1a944a0a754f44a22609aafe3a92e842aaaa54922c95a53bb9fe995c9

Contents?: true

Size: 935 Bytes

Versions: 3

Compression:

Stored size: 935 Bytes

Contents

namespace :forkcms do
  namespace :symlink do
    desc <<-DESC
      Links the document root to the current folder
      The document root is the folder that the webserver will serve, it should link to the current path.
    DESC
    task :document_root do
      on roles(:web) do
        if test("[ -L #{fetch :document_root} ]") && capture("readlink -- #{fetch :document_root}") == "#{current_path}/"
          # all is well, the symlink is correct
        elsif test("[ -d #{fetch :document_root} ]") || test("[ -f #{fetch :document_root} ]")
          error "Document root #{fetch :document_root} already exists."
          error 'To link it, issue the following command:'
          error "ln -sf #{current_path}/ #{fetch :document_root}"
        else
          execute :mkdir, '-p', File.dirname(fetch(:document_root))
          execute :ln, '-sf', "#{current_path}/", fetch(:document_root)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano-forkcms-3.0.0 lib/capistrano/tasks/symlink.rake
capistrano-forkcms-2.0.4 lib/capistrano/tasks/symlink.rake
capistrano-forkcms-2.0.3 lib/capistrano/tasks/symlink.rake