wslave 0.0.1 → 0.0.2
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/base/Capfile +10 -0
- data/base/Dockerfile +18 -0
- data/base/Gemfile +19 -0
- data/base/Rakefile +45 -0
- data/base/config/deploy-tools/gen-salts.rb +21 -0
- data/base/config/deploy-tools/gen-wp-config.rb +18 -0
- data/base/config/deploy-tools/wp-config.php.erb +97 -0
- data/base/config/deploy-tools/wp-config.php.local +96 -0
- data/base/config/deploy.rb +9 -0
- data/base/config/deploy/production.rb +130 -0
- data/base/config/deploy/staging.rb +130 -0
- data/base/docker-compose.yml +28 -0
- data/base/public/wp-config.php +96 -0
- data/lib/wslave_docker.rb +32 -0
- data/lib/wslave_new.rb +36 -0
- data/lib/wslave_sage.rb +9 -0
- data/lib/wslave_tools.rb +36 -0
- data/templates/config/database.yml +16 -0
- data/templates/config/definitions.yml +12 -0
- data/wslave.gemspec +27 -0
- metadata +21 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df0f722ba78348871b0a8e1ff5b7ce0f6c708f5
|
4
|
+
data.tar.gz: 13522f3886ca1bb4ee0da327b0b1585308f5f83b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a82e995669f06f918842f1669bd52f203c075ab822e77915a0f31622d750072272c077346b996b8907e99442ab7db8631559383b3b66080ba43359c8095f4feb
|
7
|
+
data.tar.gz: 90120ae043b34d6118afb8d3f4ebf31658816a270ab44bd394cb023c19b3999cbb582b5308e7cfdb9ceb41240965e7a2ccb90dc8ba82f104ecd2654d280c6a58
|
data/base/Capfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "capistrano/setup"
|
2
|
+
|
3
|
+
require "capistrano/deploy"
|
4
|
+
|
5
|
+
require "capistrano/scm/git"
|
6
|
+
install_plugin Capistrano::SCM::Git
|
7
|
+
require "capistrano/scm/git-with-submodules"
|
8
|
+
install_plugin Capistrano::SCM::Git::WithSubmodules
|
9
|
+
|
10
|
+
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
|
data/base/Dockerfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
FROM php:5.6-apache
|
2
|
+
|
3
|
+
RUN a2enmod rewrite
|
4
|
+
RUN service apache2 restart
|
5
|
+
RUN apt-get update \
|
6
|
+
&& apt-get install -y libpng12-dev libjpeg-dev mysql-client \
|
7
|
+
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
|
8
|
+
&& docker-php-ext-install gd \
|
9
|
+
&& docker-php-ext-install mbstring \
|
10
|
+
&& docker-php-ext-install mysql \
|
11
|
+
&& docker-php-ext-install mysqli \
|
12
|
+
&& docker-php-ext-install pdo \
|
13
|
+
&& docker-php-ext-install pdo_mysql \
|
14
|
+
&& docker-php-ext-install opcache \
|
15
|
+
&& apt-get clean
|
16
|
+
RUN adduser www-data root
|
17
|
+
RUN mkdir /db \
|
18
|
+
&& chmod 777 /db
|
data/base/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem 'rb-inotify', require: false
|
7
|
+
gem 'rb-fsevent', require: false
|
8
|
+
gem 'guard'
|
9
|
+
gem 'guard-rspec'
|
10
|
+
gem 'rubocop'
|
11
|
+
gem 'guard-rubocop'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem 'rspec'
|
16
|
+
gem 'emojidex-vectors', github: 'emojidex/emojidex-vectors'
|
17
|
+
#gem 'emojidex-vectors', path: '../emojidex-vectors'
|
18
|
+
gem 'emojidex-rasters', github: 'emojidex/emojidex-rasters'
|
19
|
+
end
|
data/base/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
def rm_dbfile(profile)
|
4
|
+
puts "Deleting db/#{profile}/wordpress.sql"
|
5
|
+
FileUtils.rm("db/#{profile}/wordpress.sql") if File.exist?("db/#{profile}/wordpress.sql")
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :db do
|
9
|
+
namespace :dev do
|
10
|
+
desc 'Backup development container database to db/dev (container must be running)'
|
11
|
+
task :backup do
|
12
|
+
rm_dbfile('dev')
|
13
|
+
puts "Creating backup of development database..."
|
14
|
+
sh 'docker-compose exec db sh -c "exec mysqldump --single-transaction -hlocalhost -uroot -pwordpress wordpress > /db/wordpress.sql"'
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Set the development container database image to the active image'
|
18
|
+
task :activate do
|
19
|
+
rm_dbfile('active')
|
20
|
+
FileUtils.cp('db/dev/wordpress.sql', 'db/active/wordpress.sql')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Backup and activate the development container database (container must be running)'
|
25
|
+
task :dev do
|
26
|
+
Rake::Task['db:dev:backup'].invoke
|
27
|
+
Rake::Task['db:dev:activate'].invoke
|
28
|
+
end
|
29
|
+
|
30
|
+
namespace :staging do
|
31
|
+
desc 'Set the staging database backup to the active database'
|
32
|
+
task :activate do
|
33
|
+
rm_dbfile('active')
|
34
|
+
FileUtils.cp('db/staging/wordpress.sql', 'db/active/wordpress.sql')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
namespace :production do
|
39
|
+
desc 'Set the production database backup to the active database'
|
40
|
+
task :activate do
|
41
|
+
rm_dbfile('active')
|
42
|
+
FileUtils.cp('db/production/wordpress.sql', 'db/active/wordpress.sql')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
config_path = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
5
|
+
|
6
|
+
if File.exist?("#{config_path}/salts.yml")
|
7
|
+
puts "Salts already generated! Refusing to overwrite them!"
|
8
|
+
else
|
9
|
+
salts = {
|
10
|
+
AUTH_KEY: SecureRandom.base64(24),
|
11
|
+
SECURE_AUTH_KEY: SecureRandom.base64(24),
|
12
|
+
LOGGED_IN_KEY: SecureRandom.base64(24),
|
13
|
+
NONCE_KEY: SecureRandom.base64(24),
|
14
|
+
AUTH_SALT: SecureRandom.base64(24),
|
15
|
+
SECURE_AUTH_SALT: SecureRandom.base64(24),
|
16
|
+
LOGGED_IN_SALT: SecureRandom.base64(24),
|
17
|
+
NONCE_SALT: SecureRandom.base64(24)
|
18
|
+
}
|
19
|
+
|
20
|
+
File.open("#{config_path}/salts.yml", 'w') {|f| f.write salts.to_yaml }
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'yaml'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
def GenerateWPConfig(profile = 'production', out_path = './')
|
6
|
+
require_relative 'gen-salts' # Generate salts if necessary
|
7
|
+
|
8
|
+
config_path = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
9
|
+
vars = {}
|
10
|
+
vars[:profile] = profile.to_sym
|
11
|
+
vars[:db_info] = YAML.load_file("#{config_path}/database.yml")
|
12
|
+
vars[:salt] = YAML.load_file("#{config_path}/salts.yml")
|
13
|
+
|
14
|
+
erb_source = File.read("#{config_path}/deploy-tools/wp-config.php.erb")
|
15
|
+
rend = ERB.new(erb_source)
|
16
|
+
res = rend.result(OpenStruct.new(vars).instance_eval { binding })
|
17
|
+
File.write("#{out_path}/wp-config.php", res)
|
18
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* The base configuration for WordPress
|
4
|
+
*
|
5
|
+
* The wp-config.php creation script uses this file during the
|
6
|
+
* installation. You don't have to use the web site, you can
|
7
|
+
* copy this file to "wp-config.php" and fill in the values.
|
8
|
+
*
|
9
|
+
* This file contains the following configurations:
|
10
|
+
*
|
11
|
+
* * MySQL settings
|
12
|
+
* * Secret keys
|
13
|
+
* * Database table prefix
|
14
|
+
* * ABSPATH
|
15
|
+
*
|
16
|
+
* @link https://codex.wordpress.org/Editing_wp-config.php
|
17
|
+
*
|
18
|
+
* @package WordPress
|
19
|
+
*/
|
20
|
+
|
21
|
+
// ** MySQL settings - You can get this info from your web host ** //
|
22
|
+
/** The name of the database for WordPress */
|
23
|
+
define('DB_NAME', '<%= db_info[profile]["database"] %>');
|
24
|
+
|
25
|
+
/** MySQL database username */
|
26
|
+
define('DB_USER', '<%= db_info[profile]["username"] %>');
|
27
|
+
|
28
|
+
/** MySQL database password */
|
29
|
+
define('DB_PASSWORD', '<%= db_info[profile]["password"] %>');
|
30
|
+
|
31
|
+
/** MySQL hostname */
|
32
|
+
define('DB_HOST', '<%= db_info[profile]["host"] %>');
|
33
|
+
|
34
|
+
/** Database Charset to use in creating database tables. */
|
35
|
+
define('DB_CHARSET', 'utf8');
|
36
|
+
|
37
|
+
/** The Database Collate type. Don't change this if in doubt. */
|
38
|
+
define('DB_COLLATE', '');
|
39
|
+
|
40
|
+
/**#@+
|
41
|
+
* Authentication Unique Keys and Salts.
|
42
|
+
*
|
43
|
+
* Change these to different unique phrases!
|
44
|
+
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
|
45
|
+
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
|
46
|
+
*
|
47
|
+
* @since 2.6.0
|
48
|
+
*/
|
49
|
+
define('AUTH_KEY', '<%= salt[:AUTH_KEY] %>');
|
50
|
+
define('SECURE_AUTH_KEY', '<%= salt[:SECURE_AUTH_KEY] %>');
|
51
|
+
define('LOGGED_IN_KEY', '<%= salt[:LOGGED_IN_KEY] %>');
|
52
|
+
define('NONCE_KEY', '<%= salt[:NONCE_KEY] %>');
|
53
|
+
define('AUTH_SALT', '<%= salt[:AUTH_SALT] %>');
|
54
|
+
define('SECURE_AUTH_SALT', '<%= salt[:SECURE_AUTH_SALT] %>');
|
55
|
+
define('LOGGED_IN_SALT', '<%= salt[:LOGGED_IN_SALT] %>');
|
56
|
+
define('NONCE_SALT', '<%= salt[:NONCE_SALT] %>');
|
57
|
+
|
58
|
+
/**#@-*/
|
59
|
+
|
60
|
+
/**
|
61
|
+
* WordPress Database Table prefix.
|
62
|
+
*
|
63
|
+
* You can have multiple installations in one database if you give each
|
64
|
+
* a unique prefix. Only numbers, letters, and underscores please!
|
65
|
+
*/
|
66
|
+
$table_prefix = 'wp_';
|
67
|
+
|
68
|
+
/**
|
69
|
+
* For developers: WordPress debugging mode.
|
70
|
+
*
|
71
|
+
* Change this to true to enable the display of notices during development.
|
72
|
+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
73
|
+
* in their development environments.
|
74
|
+
*
|
75
|
+
* For information on other constants that can be used for debugging,
|
76
|
+
* visit the Codex.
|
77
|
+
*
|
78
|
+
* @link https://codex.wordpress.org/Debugging_in_WordPress
|
79
|
+
*/
|
80
|
+
define('WP_DEBUG', false);
|
81
|
+
|
82
|
+
/* That's all, stop editing! Happy blogging. */
|
83
|
+
|
84
|
+
/** Absolute path to the WordPress directory. */
|
85
|
+
if ( !defined('ABSPATH') )
|
86
|
+
define('ABSPATH', dirname(__FILE__) . '/wordpress/');
|
87
|
+
|
88
|
+
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
|
89
|
+
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
|
90
|
+
define('WP_CONTENT_DIR', realpath(ABSPATH . '../../../current/public/wp-content/'));
|
91
|
+
define('WP_CONTENT_URL', WP_HOME . '/wp-content');
|
92
|
+
define('WP_TEMP_DIR', realpath(ABSPATH . '../../tmp/'));
|
93
|
+
define('FS_METHOD', 'direct');
|
94
|
+
|
95
|
+
/** Sets up WordPress vars and included files. */
|
96
|
+
require_once(ABSPATH . 'wp-settings.php');
|
97
|
+
add_filter('auto_update_theme', '__return_false');
|
@@ -0,0 +1,96 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* The base configuration for WordPress
|
4
|
+
*
|
5
|
+
* The wp-config.php creation script uses this file during the
|
6
|
+
* installation. You don't have to use the web site, you can
|
7
|
+
* copy this file to "wp-config.php" and fill in the values.
|
8
|
+
*
|
9
|
+
* This file contains the following configurations:
|
10
|
+
*
|
11
|
+
* * MySQL settings
|
12
|
+
* * Secret keys
|
13
|
+
* * Database table prefix
|
14
|
+
* * ABSPATH
|
15
|
+
*
|
16
|
+
* @link https://codex.wordpress.org/Editing_wp-config.php
|
17
|
+
*
|
18
|
+
* @package WordPress
|
19
|
+
*/
|
20
|
+
|
21
|
+
// ** MySQL settings - You can get this info from your web host ** //
|
22
|
+
/** The name of the database for WordPress */
|
23
|
+
define('DB_NAME', 'wordpress');
|
24
|
+
|
25
|
+
/** MySQL database username */
|
26
|
+
define('DB_USER', 'wordpress');
|
27
|
+
|
28
|
+
/** MySQL database password */
|
29
|
+
define('DB_PASSWORD', 'wordpress');
|
30
|
+
|
31
|
+
/** MySQL hostname */
|
32
|
+
define('DB_HOST', 'localhost');
|
33
|
+
|
34
|
+
/** Database Charset to use in creating database tables. */
|
35
|
+
define('DB_CHARSET', 'utf8');
|
36
|
+
|
37
|
+
/** The Database Collate type. Don't change this if in doubt. */
|
38
|
+
define('DB_COLLATE', '');
|
39
|
+
|
40
|
+
/**#@+
|
41
|
+
* Authentication Unique Keys and Salts.
|
42
|
+
*
|
43
|
+
* Change these to different unique phrases!
|
44
|
+
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
|
45
|
+
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
|
46
|
+
*
|
47
|
+
* @since 2.6.0
|
48
|
+
*/
|
49
|
+
define('AUTH_KEY', 'put your unique phrase here');
|
50
|
+
define('SECURE_AUTH_KEY', 'put your unique phrase here');
|
51
|
+
define('LOGGED_IN_KEY', 'put your unique phrase here');
|
52
|
+
define('NONCE_KEY', 'put your unique phrase here');
|
53
|
+
define('AUTH_SALT', 'put your unique phrase here');
|
54
|
+
define('SECURE_AUTH_SALT', 'put your unique phrase here');
|
55
|
+
define('LOGGED_IN_SALT', 'put your unique phrase here');
|
56
|
+
define('NONCE_SALT', 'put your unique phrase here');
|
57
|
+
|
58
|
+
/**#@-*/
|
59
|
+
|
60
|
+
/**
|
61
|
+
* WordPress Database Table prefix.
|
62
|
+
*
|
63
|
+
* You can have multiple installations in one database if you give each
|
64
|
+
* a unique prefix. Only numbers, letters, and underscores please!
|
65
|
+
*/
|
66
|
+
$table_prefix = 'wp_';
|
67
|
+
|
68
|
+
/**
|
69
|
+
* For developers: WordPress debugging mode.
|
70
|
+
*
|
71
|
+
* Change this to true to enable the display of notices during development.
|
72
|
+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
73
|
+
* in their development environments.
|
74
|
+
*
|
75
|
+
* For information on other constants that can be used for debugging,
|
76
|
+
* visit the Codex.
|
77
|
+
*
|
78
|
+
* @link https://codex.wordpress.org/Debugging_in_WordPress
|
79
|
+
*/
|
80
|
+
define('WP_DEBUG', false);
|
81
|
+
|
82
|
+
/* That's all, stop editing! Happy blogging. */
|
83
|
+
|
84
|
+
/** Absolute path to the WordPress directory. */
|
85
|
+
if ( !defined('ABSPATH') )
|
86
|
+
define('ABSPATH', dirname(__FILE__) . '/wordpress/');
|
87
|
+
|
88
|
+
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
|
89
|
+
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
|
90
|
+
define('WP_CONTENT_DIR', realpath(ABSPATH . '../wp-content/'));
|
91
|
+
define('WP_CONTENT_URL', WP_HOME . '/wp-content');
|
92
|
+
//define('WP_TEMP_DIR', realpath(ABSPATH . '../../tmp/'));
|
93
|
+
define('FS_METHOD', 'direct');
|
94
|
+
|
95
|
+
/** Sets up WordPress vars and included files. */
|
96
|
+
require_once(ABSPATH . 'wp-settings.php');
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
opts = YAML.load_file('config/definitions.yml')
|
4
|
+
db_info = YAML.load_file('config/database.yml')
|
5
|
+
|
6
|
+
deploy_user = opts['deployer']['user']
|
7
|
+
host_addr = opts['deployer']['host']['production']
|
8
|
+
multisite_root = opts['deployer']['root']
|
9
|
+
site_fqdn = opts['deployer']['fqdn']['production']
|
10
|
+
|
11
|
+
role :web, "#{deploy_user}@#{host_addr}"
|
12
|
+
|
13
|
+
set :tmp_dir, "#{multisite_root}/tmp"
|
14
|
+
deploy_path = "#{multisite_root}/#{site_fqdn}"
|
15
|
+
|
16
|
+
set :linked_dirs, %w{public/wp-content/uploads public/wordpress public/wp-content/upgrade public/wp-content/plugins tmp}
|
17
|
+
set :linked_files, %w{public/wp-config.php}
|
18
|
+
|
19
|
+
set :deploy_to, deploy_path
|
20
|
+
|
21
|
+
namespace :deploy do
|
22
|
+
desc "Generate wp-config.php for profile"
|
23
|
+
task :wp_config do
|
24
|
+
on roles(:web) do
|
25
|
+
invoke 'deploy:check:make_linked_dirs'
|
26
|
+
require_relative '../deploy-tools/gen-wp-config'
|
27
|
+
FileUtils.mkdir('./tmp') unless Dir.exist?('./tmp')
|
28
|
+
GenerateWPConfig('production', './tmp')
|
29
|
+
upload! './tmp/wp-config.php', "#{deploy_path}/shared/public/wp-config.php"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
task :upload_wp do
|
34
|
+
on roles(:web) do
|
35
|
+
upload! './public/wordpress', "#{deploy_path}/shared/public/", recursive: true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task :sync_wp do
|
40
|
+
on roles(:web) do
|
41
|
+
`rsync -avzPhu --delete ./public/wordpress/ #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wordpress/`
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
task :sync_content do
|
46
|
+
on roles(:web) do
|
47
|
+
`rsync -avzPhu --delete ./public/wp-content/uploads/ #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wp-content/uploads/`
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
task :upload_content do
|
52
|
+
on roles(:web) do
|
53
|
+
upload! './public/wp-content/uploads', "#{deploy_path}/shared/public/wp-content/", recursive: true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
task :sync_plugins do
|
58
|
+
on roles(:web) do
|
59
|
+
`rsync -avzPhu --delete ./public/wp-content/plugins/ #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/plugins/`
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
task :upload_plugins do
|
64
|
+
on roles(:web) do
|
65
|
+
upload! './public/wp-content/plugins', "#{deploy_path}/shared/public/", recursive: true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc 'Preform special seed tasks required on intial seed'
|
70
|
+
task :initial do
|
71
|
+
on roles(:web) do
|
72
|
+
invoke('deploy:check:directories')
|
73
|
+
invoke('deploy:check:linked_dirs')
|
74
|
+
invoke('deploy:check:make_linked_dirs')
|
75
|
+
invoke('deploy:wp_config')
|
76
|
+
invoke('deploy:upload_wp')
|
77
|
+
invoke('deploy:upload_content')
|
78
|
+
invoke('deploy')
|
79
|
+
invoke('db:seed')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
namespace :db do
|
85
|
+
desc "Backup DB"
|
86
|
+
task :backup do
|
87
|
+
on roles(:web) do
|
88
|
+
timestamp = DateTime.now
|
89
|
+
execute "mkdir -p #{deploy_path}/db/backups/production/"
|
90
|
+
execute "mysqldump --opt --user=#{db_info['production']['username']} --password=#{db_info['production']['password']} --host=#{db_info['production']['host']} #{db_info['production']['database']} > #{deploy_path}/db/backups/production/#{timestamp}.sql"
|
91
|
+
FileUtils.mkdir_p('./db/production') unless Dir.exist?('./db/production')
|
92
|
+
download! "#{deploy_path}/db/backups/production/#{timestamp}.sql", "db/production/wordpress.sql"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Clear remote backup records"
|
97
|
+
task :clear_remote_backups do
|
98
|
+
on roles(:web) do
|
99
|
+
execute "rm #{deploy_path}/db/backups/production/*.sql"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'Seed the "active" database'
|
104
|
+
task :seed do
|
105
|
+
on roles(:web) do
|
106
|
+
if File.exist? 'db/active/wordpress.sql'
|
107
|
+
execute "mkdir -p #{deploy_path}/db/"
|
108
|
+
upload! 'db/active/wordpress.sql', "#{deploy_path}/db/wordpress.sql"
|
109
|
+
execute "mysql -h#{db_info['production']['host']} -u#{db_info['production']['username']} -p#{db_info['production']['password']} #{db_info['production']['database']} < #{deploy_path}/db/wordpress.sql"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
namespace :data do
|
116
|
+
desc "Backup data"
|
117
|
+
task :backup do
|
118
|
+
on roles(:web) do
|
119
|
+
download! "#{deploy_path}/shared/public/wp-content/uploads", "./public/wp-content/", recursive: true
|
120
|
+
download! "#{deploy_path}/shared/public/wp-content/plugins", "./public/wp-content/", recursive: true
|
121
|
+
download! "#{deploy_path}/shared/public/wp-content/upgrade", "./public/wp-content/", recursive: true
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
desc 'Backup DB and remote uploads/content'
|
127
|
+
task :backup do
|
128
|
+
invoke('db:backup')
|
129
|
+
invoke('data:backup')
|
130
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
opts = YAML.load_file('config/definitions.yml')
|
4
|
+
db_info = YAML.load_file('config/database.yml')
|
5
|
+
|
6
|
+
deploy_user = opts['deployer']['user']
|
7
|
+
host_addr = opts['deployer']['host']['staging']
|
8
|
+
multisite_root = opts['deployer']['root']
|
9
|
+
site_fqdn = opts['deployer']['fqdn']['staging']
|
10
|
+
|
11
|
+
role :web, "#{deploy_user}@#{host_addr}"
|
12
|
+
|
13
|
+
set :tmp_dir, "#{multisite_root}/tmp"
|
14
|
+
deploy_path = "#{multisite_root}/#{site_fqdn}"
|
15
|
+
|
16
|
+
set :linked_dirs, %w{public/wp-content/uploads public/wordpress public/wp-content/upgrade public/wp-content/plugins tmp}
|
17
|
+
set :linked_files, %w{public/wp-config.php}
|
18
|
+
|
19
|
+
set :deploy_to, deploy_path
|
20
|
+
|
21
|
+
|
22
|
+
namespace :deploy do
|
23
|
+
desc "Generate wp-config.php for profile"
|
24
|
+
task :wp_config do
|
25
|
+
on roles(:web) do
|
26
|
+
require_relative '../deploy-tools/gen-wp-config'
|
27
|
+
FileUtils.mkdir('./tmp') unless Dir.exist?('./tmp')
|
28
|
+
GenerateWPConfig('staging', './tmp')
|
29
|
+
upload! './tmp/wp-config.php', "#{deploy_path}/shared/public/wp-config.php"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
task :upload_wp do
|
34
|
+
on roles(:web) do
|
35
|
+
upload! './public/wordpress', "#{deploy_path}/shared/public/", recursive: true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task :sync_wp do
|
40
|
+
on roles(:web) do
|
41
|
+
`rsync -avzPhu --delete ./public/wordpress/ #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wordpress/`
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
task :sync_content do
|
46
|
+
on roles(:web) do
|
47
|
+
`rsync -avzPhu --delete ./public/wp-content/uploads/ #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wp-content/uploads/`
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
task :upload_content do
|
52
|
+
on roles(:web) do
|
53
|
+
upload! './public/wp-content/uploads', "#{deploy_path}/shared/public/wp-content/", recursive: true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
task :sync_plugins do
|
58
|
+
on roles(:web) do
|
59
|
+
`rsync -avzPhu --delete ./public/wp-content/plugins/ #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/plugins/`
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
task :upload_plugins do
|
64
|
+
on roles(:web) do
|
65
|
+
upload! './public/wp-content/plugins', "#{deploy_path}/shared/public/", recursive: true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc 'Preform special seed tasks required on intial seed'
|
70
|
+
task :initial do
|
71
|
+
on roles(:web) do
|
72
|
+
invoke('deploy:check:directories')
|
73
|
+
invoke('deploy:check:linked_dirs')
|
74
|
+
invoke('deploy:check:make_linked_dirs')
|
75
|
+
invoke('deploy:wp_config')
|
76
|
+
invoke('deploy:upload_wp')
|
77
|
+
invoke('deploy:upload_content')
|
78
|
+
invoke('deploy')
|
79
|
+
invoke('db:seed')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
namespace :db do
|
85
|
+
desc "Backup DB"
|
86
|
+
task :backup do
|
87
|
+
on roles(:web) do
|
88
|
+
timestamp = DateTime.now
|
89
|
+
execute "mkdir -p #{deploy_path}/db/backups/staging/"
|
90
|
+
execute "mysqldump --opt --user=#{db_info['staging']['username']} --password=#{db_info['staging']['password']} --host=#{db_info['staging']['host']} #{db_info['staging']['database']} > #{deploy_path}/db/backups/staging/#{timestamp}.sql"
|
91
|
+
FileUtils.mkdir_p('./db/staging') unless Dir.exist?('./db/staging')
|
92
|
+
download! "#{deploy_path}/db/backups/staging/#{timestamp}.sql", "db/staging/wordpress.sql"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Clear remote backup records"
|
97
|
+
task :clear_remote_backups do
|
98
|
+
on roles(:web) do
|
99
|
+
execute "rm #{deploy_path}/db/backups/staging/*.sql"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'Seed the "active" database'
|
104
|
+
task :seed do
|
105
|
+
on roles(:web) do
|
106
|
+
if File.exist? 'db/active/wordpress.sql'
|
107
|
+
execute "mkdir -p #{deploy_path}/db/"
|
108
|
+
upload! 'db/active/wordpress.sql', "#{deploy_path}/db/wordpress.sql"
|
109
|
+
execute "mysql -h#{db_info['staging']['host']} -u#{db_info['staging']['username']} -p#{db_info['staging']['password']} #{db_info['staging']['database']} < #{deploy_path}/db/wordpress.sql"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
namespace :data do
|
116
|
+
desc "Backup data"
|
117
|
+
task :backup do
|
118
|
+
on roles(:web) do
|
119
|
+
download! "#{deploy_path}/shared/public/wp-content/uploads", "./public/wp-content/", recursive: true
|
120
|
+
download! "#{deploy_path}/shared/public/wp-content/plugins", "./public/wp-content/", recursive: true
|
121
|
+
download! "#{deploy_path}/shared/public/wp-content/upgrade", "./public/wp-content/", recursive: true
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
desc 'Backup DB and remote uploads/content'
|
127
|
+
task :backup do
|
128
|
+
invoke('db:backup')
|
129
|
+
invoke('data:backup')
|
130
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
version: '2'
|
2
|
+
|
3
|
+
services:
|
4
|
+
db:
|
5
|
+
image: mysql:5.7
|
6
|
+
volumes:
|
7
|
+
- "./db/dev:/db"
|
8
|
+
- "./db/active:/docker-entrypoint-initdb.d"
|
9
|
+
restart: always
|
10
|
+
environment:
|
11
|
+
MYSQL_ROOT_PASSWORD: wordpress
|
12
|
+
MYSQL_DATABASE: wordpress
|
13
|
+
|
14
|
+
web:
|
15
|
+
depends_on:
|
16
|
+
- db
|
17
|
+
build: .
|
18
|
+
volumes:
|
19
|
+
- "./public:/var/www/html"
|
20
|
+
ports:
|
21
|
+
- "8000:80"
|
22
|
+
restart: always
|
23
|
+
environment:
|
24
|
+
WORDPRESS_DB_HOST: db:3306
|
25
|
+
WORDPRESS_DB_PASSWORD: wordpress
|
26
|
+
volumes:
|
27
|
+
db_data:
|
28
|
+
driver: local
|
@@ -0,0 +1,96 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* The base configuration for WordPress
|
4
|
+
*
|
5
|
+
* The wp-config.php creation script uses this file during the
|
6
|
+
* installation. You don't have to use the web site, you can
|
7
|
+
* copy this file to "wp-config.php" and fill in the values.
|
8
|
+
*
|
9
|
+
* This file contains the following configurations:
|
10
|
+
*
|
11
|
+
* * MySQL settings
|
12
|
+
* * Secret keys
|
13
|
+
* * Database table prefix
|
14
|
+
* * ABSPATH
|
15
|
+
*
|
16
|
+
* @link https://codex.wordpress.org/Editing_wp-config.php
|
17
|
+
*
|
18
|
+
* @package WordPress
|
19
|
+
*/
|
20
|
+
|
21
|
+
// ** MySQL settings - You can get this info from your web host ** //
|
22
|
+
/** The name of the database for WordPress */
|
23
|
+
define('DB_NAME', 'wordpress');
|
24
|
+
|
25
|
+
/** MySQL database username */
|
26
|
+
define('DB_USER', 'root');
|
27
|
+
|
28
|
+
/** MySQL database password */
|
29
|
+
define('DB_PASSWORD', 'wordpress');
|
30
|
+
|
31
|
+
/** MySQL hostname */
|
32
|
+
define('DB_HOST', 'db');
|
33
|
+
|
34
|
+
/** Database Charset to use in creating database tables. */
|
35
|
+
define('DB_CHARSET', 'utf8');
|
36
|
+
|
37
|
+
/** The Database Collate type. Don't change this if in doubt. */
|
38
|
+
define('DB_COLLATE', '');
|
39
|
+
|
40
|
+
/**#@+
|
41
|
+
* Authentication Unique Keys and Salts.
|
42
|
+
*
|
43
|
+
* Change these to different unique phrases!
|
44
|
+
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
|
45
|
+
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
|
46
|
+
*
|
47
|
+
* @since 2.6.0
|
48
|
+
*/
|
49
|
+
define('AUTH_KEY', 'put your unique phrase here');
|
50
|
+
define('SECURE_AUTH_KEY', 'put your unique phrase here');
|
51
|
+
define('LOGGED_IN_KEY', 'put your unique phrase here');
|
52
|
+
define('NONCE_KEY', 'put your unique phrase here');
|
53
|
+
define('AUTH_SALT', 'put your unique phrase here');
|
54
|
+
define('SECURE_AUTH_SALT', 'put your unique phrase here');
|
55
|
+
define('LOGGED_IN_SALT', 'put your unique phrase here');
|
56
|
+
define('NONCE_SALT', 'put your unique phrase here');
|
57
|
+
|
58
|
+
/**#@-*/
|
59
|
+
|
60
|
+
/**
|
61
|
+
* WordPress Database Table prefix.
|
62
|
+
*
|
63
|
+
* You can have multiple installations in one database if you give each
|
64
|
+
* a unique prefix. Only numbers, letters, and underscores please!
|
65
|
+
*/
|
66
|
+
$table_prefix = 'wp_';
|
67
|
+
|
68
|
+
/**
|
69
|
+
* For developers: WordPress debugging mode.
|
70
|
+
*
|
71
|
+
* Change this to true to enable the display of notices during development.
|
72
|
+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
73
|
+
* in their development environments.
|
74
|
+
*
|
75
|
+
* For information on other constants that can be used for debugging,
|
76
|
+
* visit the Codex.
|
77
|
+
*
|
78
|
+
* @link https://codex.wordpress.org/Debugging_in_WordPress
|
79
|
+
*/
|
80
|
+
define('WP_DEBUG', false);
|
81
|
+
|
82
|
+
/* That's all, stop editing! Happy blogging. */
|
83
|
+
|
84
|
+
/** Absolute path to the WordPress directory. */
|
85
|
+
if ( !defined('ABSPATH') )
|
86
|
+
define('ABSPATH', dirname(__FILE__) . '/wordpress/');
|
87
|
+
|
88
|
+
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
|
89
|
+
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
|
90
|
+
define('WP_CONTENT_DIR', realpath(ABSPATH . '../wp-content/'));
|
91
|
+
define('WP_CONTENT_URL', WP_HOME . '/wp-content');
|
92
|
+
//define('WP_TEMP_DIR', realpath(ABSPATH . '../../tmp/'));
|
93
|
+
define('FS_METHOD', 'direct');
|
94
|
+
|
95
|
+
/** Sets up WordPress vars and included files. */
|
96
|
+
require_once(ABSPATH . 'wp-settings.php');
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'wslave_tools'
|
2
|
+
|
3
|
+
class WSlaveDocker
|
4
|
+
def initialize
|
5
|
+
puts 'Initializing WSlave Docker Control'
|
6
|
+
end
|
7
|
+
|
8
|
+
def server(force)
|
9
|
+
return unless _check()
|
10
|
+
_force_down() if force
|
11
|
+
WSlaveTools.set_dev_perms
|
12
|
+
`docker-compose up -d`
|
13
|
+
end
|
14
|
+
|
15
|
+
def stop(force, volume)
|
16
|
+
return unless _check()
|
17
|
+
_force_down() if force
|
18
|
+
`docker-compose down#{volume ? ' -v' : ''}`
|
19
|
+
end
|
20
|
+
|
21
|
+
def _check()
|
22
|
+
return true if (File.exist?("./config/.wslave") &&
|
23
|
+
File.exist?("Dockerfile") &&
|
24
|
+
File.exist?("docker-compose.yml"))
|
25
|
+
puts "This does not appear to be the root of a WSlave managed app."
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def _force_down()
|
30
|
+
`docker-compose down --remove-orphans`
|
31
|
+
end
|
32
|
+
end
|
data/lib/wslave_new.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rubygems'
|
3
|
+
require_relative 'wslave_tools'
|
4
|
+
|
5
|
+
class WSlaveNew
|
6
|
+
def initialize(path, version)
|
7
|
+
puts '⚙ Initializing Toolchain・・・'
|
8
|
+
|
9
|
+
tc_path = File.expand_path "#{__dir__}/../base/"
|
10
|
+
|
11
|
+
FileUtils.mkdir_p path
|
12
|
+
|
13
|
+
Dir.chdir path
|
14
|
+
|
15
|
+
puts " > Setting up WordPress WSlave setup in: #{path}"
|
16
|
+
FileUtils.cp_r Dir.glob("#{tc_path}/*"), path
|
17
|
+
|
18
|
+
spec = Gem::Specification::load("#{__dir__}/../wslave.gemspec")
|
19
|
+
File.open("#{path}/config/.wslave", 'w') {|f| f.write(spec.version)}
|
20
|
+
|
21
|
+
`cd #{path} && git init && git add --all && git commit -am "initial commit by wslave"`
|
22
|
+
|
23
|
+
`cd #{path} && git submodule add git://github.com/WordPress/WordPress.git public/wordpress`
|
24
|
+
`cd #{path}/public/wordpress && git checkout #{version}-branch` if version != ''
|
25
|
+
`cd #{path} && git submodule update --init --recursive public/wordpress`
|
26
|
+
FileUtils.cp_r("#{path}/public/wordpress/wp-content", "#{path}/public/wp-content")
|
27
|
+
FileUtils.mkdir("#{path}/public/wordpress/wp-content/uploads")
|
28
|
+
FileUtils.touch("#{path}/public/wordpress/wp-content/uploads/.gitkeep")
|
29
|
+
FileUtils.mkdir("#{path}/public/wordpress/wp-content/upgrade")
|
30
|
+
FileUtils.touch("#{path}/public/wordpress/wp-content/upgrade/.gitkeep")
|
31
|
+
Dir.chdir path
|
32
|
+
WSlaveTools.set_dev_perms
|
33
|
+
|
34
|
+
`cd #{path} && git add --all && git commit -am "Add and initialize WordPress#{version}"`
|
35
|
+
end
|
36
|
+
end
|
data/lib/wslave_sage.rb
ADDED
data/lib/wslave_tools.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class WSlaveTools
|
4
|
+
def self.wslave_root?()
|
5
|
+
return true if (File.exist?("./config/.wslave") &&
|
6
|
+
File.exist?("Dockerfile") &&
|
7
|
+
File.exist?("docker-compose.yml"))
|
8
|
+
puts "This does not appear to be the root of a WSlave managed app."
|
9
|
+
puts "Run command again from the root directory of a WSlave app."
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.set_dev_perms
|
14
|
+
begin
|
15
|
+
FileUtils.chown(nil, 'www-data', 'public/wp-content/themes')
|
16
|
+
FileUtils.chown(nil, 'www-data', 'public/wp-content/uploads')
|
17
|
+
FileUtils.chown(nil, 'www-data', 'public/wp-content/plugins')
|
18
|
+
FileUtils.chown(nil, 'www-data', 'public/wp-content/upgrade')
|
19
|
+
rescue Errno::EPERM
|
20
|
+
puts "!!!WARNING!!! Your user does not belong to the www-data group!\n" \
|
21
|
+
" >>> Unable to make folders writable for devlopment. <<<\n" \
|
22
|
+
" >>> You will not be able to edit files or themes in the WP dev container! <<<\n"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.update_submodules
|
27
|
+
`git submodule update --init --recursive`
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.sync
|
31
|
+
if wslave_root?
|
32
|
+
update_submodules
|
33
|
+
set_dev_perms
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/wslave.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'wslave'
|
3
|
+
s.version = '0.0.2'
|
4
|
+
s.licenses = ['GPL-3.0', 'AGPL-3.0']
|
5
|
+
s.summary = '"Word Slave" generates and controls a WordPress installation'
|
6
|
+
s.description = 'Word Slave includes the wslave command and a control library to generate a ' \
|
7
|
+
'"best practice" WordPress installation and includes a pre-rolled Docker ' \
|
8
|
+
'setup for running a development server and a Capistrano setup for deployment.'
|
9
|
+
s.authors = ['Rei Kagetsuki']
|
10
|
+
s.email = 'info@phantom.industries'
|
11
|
+
s.homepage = 'https://github.com/PhantomCreation/wslave'
|
12
|
+
|
13
|
+
s.required_ruby_version = '>= 2.0.0'
|
14
|
+
s.files = Dir.glob('lib/**/*.rb') +
|
15
|
+
Dir.glob('bin/**/*.rb') +
|
16
|
+
Dir.glob('base/**/*') +
|
17
|
+
Dir.glob('templates/**/*') +
|
18
|
+
['wslave.gemspec']
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
s.bindir = 'bin'
|
21
|
+
s.executables << 'wslave'
|
22
|
+
|
23
|
+
s.add_dependency 'thor'
|
24
|
+
s.add_dependency 'haikunator'
|
25
|
+
s.add_dependency 'capistrano', '~> 3.8.1'
|
26
|
+
s.add_dependency 'capistrano-git-with-submodules', '~> 2.0'
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wslave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
@@ -75,7 +75,27 @@ executables:
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- base/Capfile
|
79
|
+
- base/Dockerfile
|
80
|
+
- base/Gemfile
|
81
|
+
- base/Rakefile
|
82
|
+
- base/config/deploy-tools/gen-salts.rb
|
83
|
+
- base/config/deploy-tools/gen-wp-config.rb
|
84
|
+
- base/config/deploy-tools/wp-config.php.erb
|
85
|
+
- base/config/deploy-tools/wp-config.php.local
|
86
|
+
- base/config/deploy.rb
|
87
|
+
- base/config/deploy/production.rb
|
88
|
+
- base/config/deploy/staging.rb
|
89
|
+
- base/docker-compose.yml
|
90
|
+
- base/public/wp-config.php
|
78
91
|
- bin/wslave
|
92
|
+
- lib/wslave_docker.rb
|
93
|
+
- lib/wslave_new.rb
|
94
|
+
- lib/wslave_sage.rb
|
95
|
+
- lib/wslave_tools.rb
|
96
|
+
- templates/config/database.yml
|
97
|
+
- templates/config/definitions.yml
|
98
|
+
- wslave.gemspec
|
79
99
|
homepage: https://github.com/PhantomCreation/wslave
|
80
100
|
licenses:
|
81
101
|
- GPL-3.0
|