capistrano-cul 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/capistrano/cul/wp.rb +1 -0
- data/lib/capistrano/tasks/wp/migrate.cap +133 -0
- data/lib/capistrano/tasks/wp.cap +18 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6a9fce005273e3999a1dff23f21b96a1d264ea8
|
4
|
+
data.tar.gz: 6d7595486d3646d6c4e8ff31aa03530742e1eab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d672287dda12ce2d410a5f29c5b9ebbc6e436b087461fbde393c8874bc1dde1ebbc0d18abbe6be98ceb69e275f4af0de0407538a9468ca1152fea39c4aaddd
|
7
|
+
data.tar.gz: e320dcda0f88953b46c1e9dedc54ca80bafb0e94a2ace3a0f4b7652fd4f4c7d1e6e133f2fc300684808127c75057af878aa057125fceb15ccd85b60a7e225733
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/lib/capistrano/cul/wp.rb
CHANGED
@@ -0,0 +1,133 @@
|
|
1
|
+
namespace :cul do
|
2
|
+
namespace :wp do
|
3
|
+
namespace :migrate do
|
4
|
+
|
5
|
+
desc "Copies the WordPress installation from one environment to another (e.g. prod to dev)"
|
6
|
+
task :copy_from do
|
7
|
+
|
8
|
+
require_cap_params!([:wp_docroot, :wp_content_path])
|
9
|
+
|
10
|
+
# TODO: Verify that destination wordpress has already had the setup and deploy tasks run for it
|
11
|
+
set :src_wp_docroot, ask("server path to source WordPress installation (to copy from)")
|
12
|
+
#set :src_wp_docroot, '/cul/cul0/lito/vmounts/haydn/var-www/kennedyprize/html'
|
13
|
+
#set :src_wp_docroot, '/cul/cul0/ldpd/culblogs-prod-migration-copy/prod/ssl-html'
|
14
|
+
|
15
|
+
# Confirm operation because it is destructive
|
16
|
+
puts "\nWARNING: This operation will obliterate all content in environment [#{fetch(:stage)}] and replace it with content from [#{fetch(:src_wp_docroot)}]."
|
17
|
+
puts "Are you sure you want to continue?"
|
18
|
+
set :confirm, ask('"y" or "yes" to continue')
|
19
|
+
unless ['y', 'yes'].include?(fetch(:confirm))
|
20
|
+
puts 'Copy operation has been cancelled because neither "y" nor "yes" were entered.'
|
21
|
+
next
|
22
|
+
end
|
23
|
+
|
24
|
+
# Check WP version on source and destination WordPress instances
|
25
|
+
on roles(:web) do
|
26
|
+
within fetch(:src_wp_docroot) do
|
27
|
+
# Ensure that source WordPress is running the latest version
|
28
|
+
result = capture :wp, 'core', 'check-update'
|
29
|
+
unless result.index('Success')
|
30
|
+
puts 'Could not copy from source WordPress because it is not running the latest version of WordPress. Please update source before running a copy operation.'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
within fetch(:wp_docroot) do
|
35
|
+
# Ensure that destination WordPress is running the latest version
|
36
|
+
result = capture :wp, 'core', 'check-update'
|
37
|
+
unless result.index('Success')
|
38
|
+
puts "Could not copy TO destination [#{fetch(:stage)}] WordPress because it is not running the latest version of WordPress. Please update [#{fetch(:stage)}] before running a copy operation."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
on roles(:web) do
|
44
|
+
|
45
|
+
db_export_tempfile_path = ''
|
46
|
+
|
47
|
+
within fetch(:src_wp_docroot) do
|
48
|
+
# On source WordPress...
|
49
|
+
|
50
|
+
# Export source WP DB to a temporary file
|
51
|
+
db_export_tempfile_path = Dir::Tmpname.make_tmpname '/tmp/', 'db_export_tempfile.sql'
|
52
|
+
execute :wp, 'db', 'export', db_export_tempfile_path
|
53
|
+
end
|
54
|
+
|
55
|
+
within fetch(:wp_docroot) do
|
56
|
+
# On destination WordPress...
|
57
|
+
|
58
|
+
# Drop all tables
|
59
|
+
execute :wp, 'db', 'reset', '--yes'
|
60
|
+
|
61
|
+
# Read in db file
|
62
|
+
execute :wp, 'db', 'import', db_export_tempfile_path
|
63
|
+
|
64
|
+
# Delete db file now that we're done with it
|
65
|
+
execute :rm, db_export_tempfile_path
|
66
|
+
|
67
|
+
# Delete and recreate the wp-content directory
|
68
|
+
execute :rm, '-rf', fetch(:wp_content_path)
|
69
|
+
execute :mkdir, fetch(:wp_content_path)
|
70
|
+
|
71
|
+
# Copy wp content from source, ignoring .nfs* lock files
|
72
|
+
# Note that because we have the '--copy-links' flag below, we're transforming all symlinks into real file copies
|
73
|
+
rsync_params = [
|
74
|
+
'--recursive',
|
75
|
+
'--perms',
|
76
|
+
'--times',
|
77
|
+
'--devices',
|
78
|
+
'--specials',
|
79
|
+
'--copy-links'
|
80
|
+
]
|
81
|
+
# Exclude all repo-managed plugins, mu_plugins and themes
|
82
|
+
fetch(:wp_custom_plugins, {}).each do |plugin, repo_relative_path|
|
83
|
+
rsync_params << "--exclude plugins/#{plugin}"
|
84
|
+
end
|
85
|
+
fetch(:wp_custom_mu_plugins, {}).each do |mu_plugin, repo_relative_path|
|
86
|
+
rsync_params << "--exclude mu-plugins/#{mu_plugin}"
|
87
|
+
end
|
88
|
+
|
89
|
+
fetch(:wp_custom_themes, {}).each do |theme, repo_relative_path|
|
90
|
+
rsync_params << "--exclude themes/#{theme}"
|
91
|
+
end
|
92
|
+
|
93
|
+
# Exclude .nfs* lock files
|
94
|
+
rsync_params << '--exclude .nfs*'
|
95
|
+
|
96
|
+
# Define copy src
|
97
|
+
rsync_params << File.join(fetch(:src_wp_docroot), 'wp-content/')
|
98
|
+
|
99
|
+
# Define copy dest
|
100
|
+
rsync_params << fetch(:wp_content_path) + '/'
|
101
|
+
|
102
|
+
puts 'Copying wp-content. This may take a while for sites with a lot of uploads, plugins or themes...'
|
103
|
+
|
104
|
+
execute :rsync, *rsync_params
|
105
|
+
|
106
|
+
# Regenerate symlinks
|
107
|
+
invoke 'cul:wp:symlink_custom_plugins_and_themes'
|
108
|
+
|
109
|
+
# Make docroot readable and executable for "other" user so nginx, which runs as "nobody", can read
|
110
|
+
#execute :chmod, 'o+rx', fetch(:wp_docroot)
|
111
|
+
execute :find, fetch(:wp_docroot), '-type d -exec chmod o+rx "{}" \;'
|
112
|
+
execute :find, fetch(:wp_docroot), '-type f -exec chmod o+r "{}" \;'
|
113
|
+
|
114
|
+
# Invoke searchreplace task to update URL
|
115
|
+
puts "\nYou'll probably want to run the cul:wp:searchreplace command now, since it's likely that your WP URL differs between environments."
|
116
|
+
puts "Do you want to run a search and replace operation?"
|
117
|
+
set :confirm_searchreplace, ask('"y" or "yes" to continue')
|
118
|
+
if ['y', 'yes'].include?(fetch(:confirm_searchreplace))
|
119
|
+
invoke 'cul:wp:searchreplace'
|
120
|
+
else
|
121
|
+
puts '- Skipping search and replace because neither "y" nor "yes" were entered.'
|
122
|
+
end
|
123
|
+
|
124
|
+
puts "\nCopy operation complete!"
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
data/lib/capistrano/tasks/wp.cap
CHANGED
@@ -153,17 +153,28 @@ namespace :cul do
|
|
153
153
|
set :replacement_string, ask("replacement string")
|
154
154
|
puts "Are you sure you want to replace all occurrences of \"#{fetch(:search_string)}\" with \"#{fetch(:replacement_string)}\"?"
|
155
155
|
set :confirm, ask('"y" or "yes" to continue')
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
156
|
+
|
157
|
+
unless ['y', 'yes'].include?(fetch(:confirm))
|
158
|
+
puts 'Search and replace operation has been cancelled because neither "y" nor "yes" were entered.'
|
159
|
+
next
|
160
|
+
end
|
161
|
+
|
162
|
+
puts 'Running search and replace. This may take a while for large databases...'
|
163
|
+
start_time = Time.now
|
164
|
+
|
165
|
+
if fetch(:multisite, false)
|
166
|
+
puts "Since this is a multisite, you'll need to specify the source multisite url to continue:"
|
167
|
+
set :multisite_url, ask('full multisite install url (e.g. https://blogs.cul.columbia.edu)')
|
168
|
+
|
169
|
+
execute :wp, "--url=#{fetch(:multisite_url)}", 'search-replace', "'#{fetch(:search_string)}'", "'#{fetch(:replacement_string)}'", '--all-tables', '--skip-columns=guid'
|
162
170
|
else
|
163
|
-
|
171
|
+
execute :wp, 'search-replace', "'#{fetch(:search_string)}'", "'#{fetch(:replacement_string)}'", '--skip-columns=guid'
|
164
172
|
end
|
173
|
+
|
174
|
+
puts "Search and replace complete (took #{(Time.now - start_time).to_s} seconds)"
|
165
175
|
end
|
166
176
|
end
|
167
177
|
end
|
178
|
+
|
168
179
|
end
|
169
180
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-cul
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carla Galarza
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-09-
|
12
|
+
date: 2017-09-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/capistrano/cul/wp.rb
|
60
60
|
- lib/capistrano/tasks/cul.cap
|
61
61
|
- lib/capistrano/tasks/wp.cap
|
62
|
+
- lib/capistrano/tasks/wp/migrate.cap
|
62
63
|
- lib/capistrano/tasks/wp/update.cap
|
63
64
|
homepage: https://github.com/cul/capistrano-cul
|
64
65
|
licenses:
|