Sha256: 768c3aa1e1068317f4cdf183eb30098e42c5aa347921fcc30e492d86f26bc1bc

Contents?: true

Size: 2 KB

Versions: 4

Compression:

Stored size: 2 KB

Contents

configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)

configuration.load do
	# define some extra folder to create
	set :shared_children, %w(files config/frontend config/backend config/library)

	# custom events configuration
	after 'deploy:setup' do
		forkcms.link_document_root
	end

	after 'deploy:update_code' do
		forkcms.link_configs
		forkcms.link_files
	end

	# Fork CMS specific tasks
	namespace :forkcms do
		desc 'Link the config files'
		task :link_configs do

			# change the path to current_path
			run "if [ -f #{shared_path}/config/library/globals.php ]; then sed -i 's/#{version_dir}\\/[0-9]*/#{current_dir}/' #{shared_path}/config/library/globals.php; fi"
			
			# symlink the globals
			run %{
				ln -sf #{shared_path}/config/library/globals.php #{release_path}/library/globals.php 
			}
		end

		desc 'link the document root to the current/default_www-folder'
		task :link_document_root do
			# create symlink for document_root if it doesn't exists
			documentRootExists = capture("if [ ! -e #{document_root} ]; then ln -sf #{current_path}/public #{document_root}; echo 'no'; fi").chomp

			unless documentRootExists == 'no'
				warn "Warning: Document root (#{document_root}) already exists"
				warn "to link it to the Fork deploy issue the following command:"
				warn "	ln -sf #{current_path}/public #{document_root}"
			end 
		end	

		desc 'Create needed symlinks'
		task :link_files do
			# get the list of folders in /frontend/files
			folders = capture("ls -1 #{release_path}/public/userfiles").split(/\r?\n/)

			# loop the folders
			folders.each do |folder|
				# copy them to the shared path, remove them from the release and symlink them
				run %{
					cp -r #{release_path}/public/userfiles/#{folder} #{shared_path}/files/#{folder} &&
					rm -rf #{release_path}/public/userfiles/#{folder} &&
					ln -s #{shared_path}/files/#{folder} #{release_path}/public/userfiles/#{folder}
				}
			end
		end	
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fork_legacy_deploy-0.1.4 lib/forkcms_legacy_deploy/forkcms.rb
fork_legacy_deploy-0.1.3 lib/forkcms_legacy_deploy/forkcms.rb
fork_legacy_deploy-0.1.1 lib/forkcms_legacy_deploy/forkcms.rb
fork_legacy_deploy-0.1.0 lib/forkcms_deploy/forkcms.rb