forkcms_deploy 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "forkcms_deploy"
5
+ gemspec.summary = "MyCorp recipes for Capistrano"
6
+ gemspec.description = "MyCorp recipes for Capistrano"
7
+ gemspec.email = "tim@openmonkey.com"
8
+ gemspec.homepage = "http://github.com/timriley/capistrano-mycorp"
9
+ gemspec.authors = ["Tim Riley"]
10
+ end
11
+ Jeweler::GemcutterTasks.new
12
+ rescue LoadError
13
+ puts "Jeweler not available. Install it with: gem install jeweler"
14
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,22 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # don't use sudo, on most shared setups we won't have sudo-access
5
+ set :use_sudo, false
6
+
7
+ # we're on a share setup so group_writable isn't allowed
8
+ set :group_writable, false
9
+
10
+ # 3 releases should be enough.
11
+ set :keep_releases, 3
12
+
13
+ # remote caching will keep a local git repo on the server you're deploying to and simply run a fetch from that
14
+ # rather than an entire clone. This is probably the best option and will only fetch the differences each deploy
15
+ set :deploy_via, :remote_cache
16
+
17
+ # set the value for pseudo terminals in Capistrano
18
+ default_run_options[:pty] = true
19
+
20
+ # your computer must be running ssh-agent for the git checkout to work from the server to the git server
21
+ set :ssh_options, { :forward_agent => true }
22
+ end
@@ -0,0 +1,103 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # define some extra folder to create
5
+ set :shared_children, %w(files config/frontend config/backend config/library)
6
+
7
+ # custom events configuration
8
+ after 'deploy:setup' do
9
+ forkcms.link_document_root
10
+ end
11
+
12
+ after 'deploy:update_code' do
13
+ forkcms.link_configs
14
+ forkcms.link_files
15
+ end
16
+
17
+ # Fork CMS specific tasks
18
+ namespace :forkcms do
19
+ desc 'Clear the frontend and backend cache-folders'
20
+ task :clear_cached do
21
+ # remove frontend cached data
22
+ run %{
23
+ rm -rf #{current_path}/default_www/frontend/cache/cached_templates/* &&
24
+ rm -rf #{current_path}/default_www/frontend/cache/locale/* &&
25
+ rm -rf #{current_path}/default_www/frontend/cache/minified_css/* &&
26
+ rm -rf #{current_path}/default_www/frontend/cache/minified_js/* &&
27
+ rm -rf #{current_path}/default_www/frontend/cache/navigation/* &&
28
+ rm -rf #{current_path}/default_www/frontend/cache/statistics/* &&
29
+ rm -rf #{current_path}/default_www/frontend/cache/templates/*
30
+ }
31
+
32
+ # remove backend cached data
33
+ run %{
34
+ rm -rf #{current_path}/default_www/backend/cache/analytics/* &&
35
+ rm -rf #{current_path}/default_www/backend/cache/cronjobs/* &&
36
+ rm -rf #{current_path}/default_www/backend/cache/locale/* &&
37
+ rm -rf #{current_path}/default_www/backend/cache/mailmotor/* &&
38
+ rm -rf #{current_path}/default_www/backend/cache/templates/*
39
+ }
40
+ end
41
+
42
+ desc 'Link the config files'
43
+ task :link_configs do
44
+ # create config files
45
+ path_library = <<-CONFIG
46
+ <?php
47
+ // custom constant used by the init classes
48
+ define('INIT_PATH_LIBRARY', '#{current_path}/library');
49
+ ?>
50
+ CONFIG
51
+
52
+ # upload the files
53
+ put path_library, "#{shared_path}/config/frontend/config.php"
54
+ put path_library, "#{shared_path}/config/backend/config.php"
55
+
56
+ # change the path to current_path
57
+ 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"
58
+
59
+ # create dirs
60
+ run %{
61
+ mkdir -p #{release_path}/default_www/frontend/cache/config &&
62
+ mkdir -p #{release_path}/default_www/backend/cache/config
63
+ }
64
+
65
+ # symlink the globals
66
+ run %{
67
+ ln -sf #{shared_path}/config/library/globals_backend.php #{release_path}/library/globals_backend.php &&
68
+ ln -sf #{shared_path}/config/library/globals_frontend.php #{release_path}/library/globals_frontend.php &&
69
+ ln -sf #{shared_path}/config/library/globals.php #{release_path}/library/globals.php &&
70
+ ln -sf #{shared_path}/config/frontend/config.php #{release_path}/default_www/frontend/cache/config/config.php &&
71
+ ln -sf #{shared_path}/config/backend/config.php #{release_path}/default_www/backend/cache/config/config.php
72
+ }
73
+ end
74
+
75
+ desc 'link the document root to the current/default_www-folder'
76
+ task :link_document_root do
77
+ # create symlink for document_root if it doesn't exists
78
+ documentRootExists = capture("if [ ! -e #{document_root} ]; then ln -sf #{current_path}/default_www #{document_root}; echo 'no'; fi").chomp
79
+
80
+ unless documentRootExists == 'no'
81
+ warn 'Warning: Document root (#{document_root}) already exists'
82
+ warn 'to link it to the Fork deploy issue the following command:'
83
+ warn ' ln -sf #{current_path}/default_www #{document_root}'
84
+ end
85
+ end
86
+
87
+ desc 'Create needed symlinks'
88
+ task :link_files do
89
+ # get the list of folders in /frontend/files
90
+ folders = capture("ls -1 #{release_path}/default_www/frontend/files").split(/\r?\n/)
91
+
92
+ # loop the folders
93
+ folders.each do |folder|
94
+ # copy them to the shared path, remove them from the release and symlink them
95
+ run %{
96
+ cp -r #{release_path}/default_www/frontend/files/#{folder} #{shared_path}/files/#{folder} &&
97
+ rm -rf #{release_path}/default_www/frontend/files/#{folder} &&
98
+ ln -s #{shared_path}/files/#{folder} #{release_path}/default_www/frontend/files/#{folder}
99
+ }
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,31 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # Deployment process
5
+ namespace :deploy do
6
+ desc 'Prepares the servers for deployment.'
7
+ task :setup, :except => { :no_release => true } do
8
+ # this method is overwritten because Fork CMS isn't a Rails-application
9
+
10
+ # define folders to create
11
+ dirs = [deploy_to, releases_path, shared_path]
12
+
13
+ # add folder that aren't standard
14
+ dirs += shared_children.map { |d| File.join(shared_path, d) }
15
+
16
+ # create the dirs
17
+ run %{
18
+ #{try_sudo} mkdir -p #{dirs.join(' ')} &&
19
+ #{try_sudo} chmod g+w #{dirs.join(' ')}
20
+ }
21
+ end
22
+
23
+ task :finalize_update, :except => { :no_release => true } do
24
+ # Fork CMS isn't a Rails-application so don't do Rails specific stuff
25
+ run 'chmod -R g+w #{latest_release}' if fetch(:group_writable, true)
26
+ end
27
+
28
+ # overrule restart
29
+ task :restart do; end
30
+ end
31
+ end
@@ -0,0 +1,2 @@
1
+ require 'forkcms_deploy/forkcms'
2
+ require 'forkcms_deploy/overwrites'
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forkcms_deploy
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Tim Riley
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-28 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: MyCorp recipes for Capistrano
23
+ email: tim@openmonkey.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.md
30
+ files:
31
+ - README.md
32
+ - Rakefile
33
+ - VERSION
34
+ - lib/forkcms_deploy.rb
35
+ - lib/forkcms_deploy/defaults.rb
36
+ - lib/forkcms_deploy/forkcms.rb
37
+ - lib/forkcms_deploy/overwrites.rb
38
+ has_rdoc: true
39
+ homepage: http://github.com/timriley/capistrano-mycorp
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ hash: 3
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.7
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: MyCorp recipes for Capistrano
72
+ test_files: []
73
+