wpcap 0.2.2.3 → 0.2.3
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.
- data/README.md +23 -5
- data/lib/wpcap/recipes/backups.rb +40 -0
- data/lib/wpcap/recipes/mysql.rb +1 -2
- data/lib/wpcap/recipes/templates/deploy-stage.rb.erb +1 -1
- data/lib/wpcap/recipes/templates/deploy.rb.erb +6 -2
- data/lib/wpcap/recipes/templates/nginx_php.erb +1 -2
- data/lib/wpcap/recipes/wordpress.rb +10 -3
- data/lib/wpcap/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -4,12 +4,12 @@ WPcap is a set of capistrano recipes designed to deploy wordpress instaliations
|
|
4
4
|
|
5
5
|
WPcap is opinionated, and currently reasonably narrow minded.
|
6
6
|
|
7
|
-
WPcap
|
7
|
+
WPcap expectations
|
8
8
|
|
9
|
-
* Local Macine is a Mac running MAMP
|
9
|
+
* Local Macine is a Mac running MAMP (for now)
|
10
10
|
* Remote Server is a brand new Ubuntu Server
|
11
|
-
* Passwordless access to remote server has be established (ssh keys)
|
12
|
-
*
|
11
|
+
* Passwordless access to remote server has be established (ssh keys) **Capistrano Requirment**
|
12
|
+
* Using a SMTP Mailer Plugin for E-Mail delivery ie. wp-mail-smtp
|
13
13
|
|
14
14
|
WPcap server configuration
|
15
15
|
|
@@ -18,6 +18,11 @@ WPcap server configuration
|
|
18
18
|
* mysql > 5.5
|
19
19
|
* memcached
|
20
20
|
* varnish (Optional)
|
21
|
+
|
22
|
+
Base
|
23
|
+
* git
|
24
|
+
* debconf-utils
|
25
|
+
* python-software-properties
|
21
26
|
|
22
27
|
## Installation
|
23
28
|
|
@@ -31,6 +36,10 @@ Create a new projet
|
|
31
36
|
|
32
37
|
wpcap create mynewproject
|
33
38
|
|
39
|
+
Convert an existing project to WPcap (Incomplete)
|
40
|
+
|
41
|
+
wpcap build PATH-TO-WORDPRESS-FOLDER
|
42
|
+
|
34
43
|
Build a remote server
|
35
44
|
|
36
45
|
cap deploy:install
|
@@ -51,11 +60,20 @@ Pull Remote Database and Assets to local enviroment
|
|
51
60
|
|
52
61
|
cap db:pull
|
53
62
|
|
63
|
+
List Backups and Resotre
|
64
|
+
|
65
|
+
cap backups
|
66
|
+
|
54
67
|
## Todo
|
55
68
|
|
56
69
|
* Covert a predone wordpress install into a wpcap style directory
|
57
70
|
* Do not require MAMP
|
58
|
-
* Allow users to customize templates by placing them in
|
71
|
+
* Allow users to customize templates by placing them in their config directory (think devise generators for views)
|
72
|
+
* Automate mysql_secure_installation
|
73
|
+
* Offsite (s3) Backups
|
74
|
+
* Backup Asset Directory
|
75
|
+
* Add Sendmail Receipe and Config (Maybe?)
|
76
|
+
|
59
77
|
|
60
78
|
|
61
79
|
## Contributing
|
@@ -0,0 +1,40 @@
|
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
4
|
+
|
5
|
+
configuration.load do
|
6
|
+
namespace :backups do
|
7
|
+
|
8
|
+
#Hooks
|
9
|
+
before :deploy, 'db:mysql:dump'
|
10
|
+
|
11
|
+
|
12
|
+
#Taks
|
13
|
+
desc "List all available backups"
|
14
|
+
task :default, :except => { :no_release => true } do
|
15
|
+
db.mysql.restore
|
16
|
+
end
|
17
|
+
|
18
|
+
desc <<-DESC
|
19
|
+
Clean up old releases. By default, the last 5 backups are kept on each \
|
20
|
+
server (though you can change this with the keep_releases variable). All \
|
21
|
+
other deployed revisions are removed from the servers. By default, this \
|
22
|
+
will use sudo to clean up the old releases, but if sudo is not available \
|
23
|
+
for your environment, set the :use_sudo variable to false instead.
|
24
|
+
DESC
|
25
|
+
task :cleanup, :except => { :no_release => true } do
|
26
|
+
count = fetch(:keep_backups, 5).to_i
|
27
|
+
local_backups = capture("ls -xt #{backups_path}").split.reverse
|
28
|
+
if count >= local_backups.length
|
29
|
+
logger.important "no old backups to clean up"
|
30
|
+
else
|
31
|
+
logger.info "keeping #{count} of #{local_backups.length} backups"
|
32
|
+
directories = (local_backups - local_backups.last(count)).map { |release|
|
33
|
+
File.join(backups_path, release) }.join(" ")
|
34
|
+
|
35
|
+
try_sudo "rm -rf #{directories}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
data/lib/wpcap/recipes/mysql.rb
CHANGED
@@ -261,7 +261,6 @@ configuration.load do
|
|
261
261
|
|
262
262
|
def create_db_if_missing(environment = stage)
|
263
263
|
unless database_exits?(environment)
|
264
|
-
create_yaml
|
265
264
|
sql = <<-SQL
|
266
265
|
CREATE DATABASE #{db_database};
|
267
266
|
GRANT ALL PRIVILEGES ON #{db_database}.* TO #{db_username}@#{db_host} IDENTIFIED BY '#{db_password}';
|
@@ -297,7 +296,7 @@ configuration.load do
|
|
297
296
|
before "db:mysql:pull", "db:mysql:create_local_db"
|
298
297
|
after "deploy:update_code" , "db:mysql:prepare_enviroment"
|
299
298
|
after "deploy:setup", "db:mysql:create"
|
300
|
-
|
299
|
+
|
301
300
|
end
|
302
301
|
end
|
303
302
|
end
|
@@ -5,6 +5,6 @@
|
|
5
5
|
# cap production deploy
|
6
6
|
|
7
7
|
set :user, "root"
|
8
|
-
set :application_url, "your full url here
|
8
|
+
set :application_url, "your full url here including the protocol (https/http)"
|
9
9
|
server "your server address or url here", :web, :app, :db, primary: true
|
10
10
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
set :application, "your application web address here" #Your Project webaddress
|
1
|
+
set :application, "your application web address here" #Your Project's webaddress
|
3
2
|
set :repository, "your repo location here"
|
4
3
|
set :branch, :master
|
5
4
|
|
@@ -15,6 +14,10 @@ set(:deploy_to) { "/home/#{user}/#{application}" }
|
|
15
14
|
|
16
15
|
# Database Backup Path
|
17
16
|
set :backups_path, "#{deploy_to}/backups"
|
17
|
+
set :keep_backups, 5
|
18
|
+
|
19
|
+
# if you want to clean up old backups on each deploy uncomment this:
|
20
|
+
# after :deploy , 'backups:cleanup'
|
18
21
|
|
19
22
|
# Wordpress Uploads Path
|
20
23
|
set :uploads_path, "assets"
|
@@ -33,3 +36,4 @@ require "wpcap/recipes/mysql"
|
|
33
36
|
require "wpcap/recipes/nginx"
|
34
37
|
require "wpcap/recipes/php"
|
35
38
|
require "wpcap/recipes/wordpress"
|
39
|
+
require "wpcap/recipes/backups"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
server {
|
2
2
|
listen 80;
|
3
|
-
server_name <%= application %>, <%= application_url.gsub(/^https?:\/\//, "") %> ;
|
3
|
+
server_name <%= application %>, <%= application_url.gsub(/^https?:\/\//, "") %>, www.<%= application %>, www.<%= application_url.gsub(/^https?:\/\//, "") %> ;
|
4
4
|
root <%= current_path %>/app;
|
5
5
|
index index.php;
|
6
6
|
|
@@ -34,7 +34,6 @@ server {
|
|
34
34
|
location / {
|
35
35
|
try_files $uri $uri/ /index.php?$args;
|
36
36
|
}
|
37
|
-
|
38
37
|
|
39
38
|
location ~ \.php$ {
|
40
39
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
@@ -52,7 +52,10 @@ configuration.load do
|
|
52
52
|
# set correct permissions
|
53
53
|
run "chmod -R 755 #{latest_release}/app/wp-content/plugins"
|
54
54
|
run "chmod -R 775 #{shared_path}/uploads"
|
55
|
-
run "chmod -R
|
55
|
+
run "chmod -R 775 #{shared_path}/cache"
|
56
|
+
run "chmod -R 755 #{latest_release}"
|
57
|
+
run "chown -R -h #{user}:www-data #{latest_release}"
|
58
|
+
run "chown -R -h #{user}:www-data #{shared_path}"
|
56
59
|
end
|
57
60
|
|
58
61
|
desc "[internal] Touches up the released code. This is called by update_code after the basic deploy finishes."
|
@@ -167,8 +170,8 @@ configuration.load do
|
|
167
170
|
desc "[internal] Protect system files"
|
168
171
|
task :protect, :except => { :no_release => true } do
|
169
172
|
run "chmod 444 #{latest_release}/app/wp-config.php*"
|
170
|
-
|
171
|
-
run "cd #{shared_path}/uploads && chown -R #{user} . && chmod 755 -R ."
|
173
|
+
# run "cd #{current_path} && chown -R #{user} . && find . -type d -print0 | xargs -0 chmod 755"
|
174
|
+
#run "cd #{shared_path}/uploads && chown -R #{user} . && chmod 755 -R ."
|
172
175
|
end
|
173
176
|
|
174
177
|
desc "[internal] get current wp template from local db"
|
@@ -176,6 +179,10 @@ configuration.load do
|
|
176
179
|
db.mysql.prepare_env(:development)
|
177
180
|
template = run_locally "#{local_mysql_path}mysql -u #{db_username} -p#{db_password} #{db_database} -e 'SELECT `option_value` FROM `#{db_prefix}options` WHERE `option_name` = \"template\"'"
|
178
181
|
set(:wp_template) { template.split("\n")[1] }
|
182
|
+
unless wp_template.length > 1
|
183
|
+
Wpcap::Utility.error("No Wordpress Template found (Is your local Database Running?)")
|
184
|
+
abort
|
185
|
+
end
|
179
186
|
end
|
180
187
|
before "nginx:setup", "wordpress:current_wp_template"
|
181
188
|
|
data/lib/wpcap/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wpcap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/wpcap.rb
|
61
61
|
- lib/wpcap/backup.rb
|
62
62
|
- lib/wpcap/command.rb
|
63
|
+
- lib/wpcap/recipes/backups.rb
|
63
64
|
- lib/wpcap/recipes/base.rb
|
64
65
|
- lib/wpcap/recipes/check.rb
|
65
66
|
- lib/wpcap/recipes/memcached.rb
|