wordmove 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.mdown CHANGED
@@ -20,8 +20,7 @@ Beware!
20
20
 
21
21
  From version 1.0 we have decided to change wordmove flags' behaviour: they used to tell
22
22
  wordmove which options to **skip**, now they tell instead which options to **include**.
23
- In the Movefile, we have also changed in the ssh subsection the "username" field to be
24
- just "user".
23
+ In the Movefile, we have also changed all "username" fields to be just "user".
25
24
 
26
25
  So please, be very careful when upgrading :heart:
27
26
 
@@ -13,18 +13,18 @@ Feature: Generating Movefile
13
13
  vhost: "http://vhost.local"
14
14
  wordpress_path: "~/dev/sites/your_site"
15
15
  database:
16
- username: "username"
16
+ user: "user"
17
17
  password: "password"
18
18
  host: "host"
19
19
  remote:
20
20
  vhost: "http://remote.com"
21
21
  wordpress_path: "/var/www/your_site"
22
22
  database:
23
- username: "username"
23
+ user: "user"
24
24
  password: "password"
25
25
  host: "host"
26
26
  ssh:
27
- username: "username"
27
+ user: "user"
28
28
  password: "password"
29
29
  host: "host"
30
30
  """
@@ -153,8 +153,8 @@ class MySQLDump
153
153
  }
154
154
  }
155
155
 
156
- function get_connection($db_host, $db_username, $db_password, $db_name, $error = NULL) {
157
- $db_connection = new mysqli($db_host, $db_username, $db_password);
156
+ function get_connection($db_host, $db_user, $db_password, $db_name, $error = NULL) {
157
+ $db_connection = new mysqli($db_host, $db_user, $db_password);
158
158
  if (!$db_connection || !$db_connection->select_db($db_name)) {
159
159
  if ($db_connection) {
160
160
  $error = mysqli_connect_error();
@@ -167,7 +167,7 @@ function get_connection($db_host, $db_username, $db_password, $db_name, $error =
167
167
  }
168
168
 
169
169
  $db_host = '<%= escape_php db[:host] %>';
170
- $db_username = '<%= escape_php db[:user] %>';
170
+ $db_user = '<%= escape_php db[:user] %>';
171
171
  $db_password = '<%= escape_php db[:password] %>';
172
172
  $db_name = '<%= escape_php_literal db[:name] %>';
173
173
  $shared_key = '<%= password %>';
@@ -175,7 +175,7 @@ $shared_key = '<%= password %>';
175
175
  $mysql_error = '';
176
176
 
177
177
  if ($_GET['shared_key'] == $shared_key) {
178
- $connection = get_connection($db_host, $db_username, $db_password, $db_name, &$mysql_error);
178
+ $connection = get_connection($db_host, $db_user, $db_password, $db_name, &$mysql_error);
179
179
  $dump = new MySQLDump($connection);
180
180
  $dump->send('dump.mysql');
181
181
  }
@@ -10,7 +10,7 @@ if ($_GET['shared_key'] != $shared_key) {
10
10
  // Database configuration
11
11
 
12
12
  $db_server = '<%= escape_php db[:host] %>';
13
- $db_username = '<%= escape_php db[:username] %>';
13
+ $db_user = '<%= escape_php db[:user] %>';
14
14
  $db_password = '<%= escape_php db[:password] %>';
15
15
  $db_name = '<%= escape_php db[:name] %>';
16
16
 
@@ -324,7 +324,7 @@ if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SER
324
324
  // Connect to the database, set charset and execute pre-queries
325
325
 
326
326
  if (!$error && !TESTMODE)
327
- { $dbconnection = @mysql_connect($db_server,$db_username,$db_password);
327
+ { $dbconnection = @mysql_connect($db_server,$db_user,$db_password);
328
328
  if ($dbconnection)
329
329
  $db = mysql_select_db($db_name);
330
330
  if (!$dbconnection || !$db)
@@ -61,7 +61,7 @@ module Wordmove
61
61
  remote_mysql_dump_path = remote_wpcontent_path("database_dump.sql")
62
62
 
63
63
  locally do |host|
64
- host.run "mysqldump", "--host=#{config.local.database.host}", "--user=#{config.local.database.username}", "--password=#{config.local.database.password}", config.local.database.name, :stdout => local_mysql_dump_path
64
+ host.run "mysqldump", "--host=#{config.local.database.host}", "--user=#{config.local.database.user}", "--password=#{config.local.database.password}", config.local.database.name, :stdout => local_mysql_dump_path
65
65
  if options.adapt_sql
66
66
  Wordmove::SqlMover.new(local_mysql_dump_path, config.local, config.remote).move!
67
67
  else
@@ -73,7 +73,7 @@ module Wordmove
73
73
 
74
74
  remotely do |host|
75
75
  host.download_file local_mysql_dump_path, remote_mysql_dump_path
76
- host.run "mysql", "--user=#{config.remote.database.username}", "--password=#{config.remote.database.password}", "--host=#{config.remote.database.host}", "--database=#{config.remote.database.name}", :stdin => remote_mysql_dump_path
76
+ host.run "mysql", "--user=#{config.remote.database.user}", "--password=#{config.remote.database.password}", "--host=#{config.remote.database.host}", "--database=#{config.remote.database.name}", :stdin => remote_mysql_dump_path
77
77
  host.run "rm", remote_mysql_dump_path
78
78
  end
79
79
 
@@ -88,7 +88,7 @@ module Wordmove
88
88
  remote_mysql_dump_path = remote_wpcontent_path("database_dump.sql")
89
89
 
90
90
  remotely do |host|
91
- host.run "mysqldump", "--host=#{config.remote.database.host}", "--user=#{config.remote.database.username}", "--password=#{config.remote.database.password}", config.remote.database.name, :stdout => remote_mysql_dump_path
91
+ host.run "mysqldump", "--host=#{config.remote.database.host}", "--user=#{config.remote.database.user}", "--password=#{config.remote.database.password}", config.remote.database.name, :stdout => remote_mysql_dump_path
92
92
  host.upload_file remote_mysql_dump_path, local_mysql_dump_path
93
93
  end
94
94
 
@@ -100,7 +100,7 @@ module Wordmove
100
100
  file.write "UPDATE #{options_table} SET option_value=\"#{config.local.vhost}\" WHERE option_name=\"siteurl\" OR option_name=\"home\";\n"
101
101
  end
102
102
  end
103
- host.run "mysql", "--user=#{config.local.database.username}", "--password=#{config.local.database.password}", "--host=#{config.local.database.host}", "--database=#{config.local.database.name}", :stdin => local_mysql_dump_path
103
+ host.run "mysql", "--user=#{config.local.database.user}", "--password=#{config.local.database.password}", "--host=#{config.local.database.host}", "--database=#{config.local.database.name}", :stdin => local_mysql_dump_path
104
104
  host.run "rm", local_mysql_dump_path
105
105
  end
106
106
 
@@ -109,7 +109,7 @@ module Wordmove
109
109
  def mysql_dump_command(options, save_to_path)
110
110
  arguments = [ "mysqldump" ]
111
111
  arguments << "--host=#{options[:host]}" if options[:host].present?
112
- arguments << "--user=#{options[:username]}" if options[:username].present?
112
+ arguments << "--user=#{options[:user]}" if options[:user].present?
113
113
  arguments << "--password=#{options[:password]}" if options[:password].present?
114
114
  arguments << "--default-character-set=#{options[:charset]}" if options[:charset].present?
115
115
  arguments << options[:name]
@@ -119,7 +119,7 @@ module Wordmove
119
119
  def mysql_import_command(dump_path, options)
120
120
  arguments = [ "mysql" ]
121
121
  arguments << "--host=#{options[:host]}" if options[:host].present?
122
- arguments << "--user=#{options[:username]}" if options[:username].present?
122
+ arguments << "--user=#{options[:user]}" if options[:user].present?
123
123
  arguments << "--password=#{options[:password]}" if options[:password].present?
124
124
  arguments << "--database=#{options[:name]}"
125
125
  Escape.shell_command(arguments) + " < #{dump_path}"
@@ -3,7 +3,7 @@ local:
3
3
  wordpress_path: "~/dev/sites/your_site"
4
4
  database:
5
5
  name: "database_name"
6
- username: "user"
6
+ user: "user"
7
7
  password: "password"
8
8
  host: "127.0.0.1"
9
9
  remote:
@@ -11,7 +11,7 @@ remote:
11
11
  wordpress_path: "/var/www/your_site"
12
12
  database:
13
13
  name: "database_name"
14
- username: "user"
14
+ user: "user"
15
15
  password: "password"
16
16
  host: "host"
17
17
  ssh: # also ftp is allowed
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordmove
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-12-07 00:00:00.000000000 Z
12
+ date: 2012-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -186,7 +186,6 @@ files:
186
186
  - lib/wordmove/deployer/ssh.rb
187
187
  - lib/wordmove/generators/Movefile
188
188
  - lib/wordmove/generators/movefile.rb
189
- - lib/wordmove/hosts/remote_host.rb
190
189
  - lib/wordmove/logger.rb
191
190
  - lib/wordmove/sql_mover.rb
192
191
  - lib/wordmove/version.rb
@@ -1,137 +0,0 @@
1
- require 'net/ssh'
2
- require 'net/scp'
3
- require 'net/ssh/gateway'
4
-
5
- module Wordmove
6
- class RemoteHost < LocalHost
7
-
8
- alias :locally_run :run
9
-
10
- attr_reader :session
11
-
12
- def initialize(options = {})
13
- super
14
- end
15
-
16
- def session
17
- if options.ssh.nil?
18
- raise Thor::Error, "No SSH credentials provided on Movefile!"
19
- end
20
-
21
- ssh_extras = {}
22
- [ :port, :password ].each do |p|
23
- ssh_extras.merge!( { p => options.ssh[p] } ) if options.ssh[p]
24
- end
25
-
26
- if options.ssh.gateway.nil?
27
- logger.verbose "Connecting to #{options.ssh.host}..." unless @session.present?
28
- @session ||= Net::SSH.start(options.ssh.host, options.ssh.username, ssh_extras)
29
- else
30
- logger.verbose "Connecting to #{options.ssh.host} through the gateway..." unless @session.present?
31
- @session ||= gateway.ssh(options.ssh.host, options.ssh.username, ssh_extras)
32
- end
33
-
34
- @session
35
- end
36
-
37
- def gateway
38
- if options.ssh.gateway.nil?
39
- raise Thor::Error, "No SSH credentials provided on Movefile!"
40
- end
41
-
42
- ssh_extras = {}
43
- [ :port, :password ].each do |p|
44
- ssh_extras.merge!( { p => options.ssh.gateway[p] } ) if options.ssh.gateway[p]
45
- end
46
-
47
- logger.verbose "Connecting to #{options.ssh.gateway.host}..." unless @gateway.present?
48
- @gateway ||= Net::SSH::Gateway.new(options.ssh.gateway.host, options.ssh.gateway.username, ssh_extras )
49
-
50
- @gateway
51
- end
52
-
53
- def close
54
- session.close
55
- if options.ssh.gateway.present?
56
- gateway.close(session.transport.port)
57
- end
58
- end
59
-
60
- def upload_file(source_file, destination_file)
61
- logger.verbose "Copying remote #{source_file} to #{destination_file}..."
62
- session.scp.download! source_file, destination_file
63
- end
64
-
65
- def download_file(source_file, destination_file)
66
- logger.verbose "Copying local #{source_file} to #{destination_file}..."
67
- session.scp.upload! source_file, destination_file
68
- end
69
-
70
- def download_dir(source_dir, destination_dir)
71
- destination_dir = ":#{destination_dir}"
72
- destination_dir = "#{options.ssh.username}@#{destination_dir}" if options.ssh.username
73
- rsync "#{source_dir}/", destination_dir
74
- end
75
-
76
- def upload_dir(source_dir, destination_dir)
77
- source_dir = ":#{source_dir}/"
78
- rsync source_dir, destination_dir
79
- end
80
-
81
- def run(*args)
82
- command = shell_command(*args)
83
- logger.verbose "Executing remotely #{command}"
84
- session.exec!(command)
85
- end
86
-
87
- private
88
-
89
- def get_host_for_options(options)
90
- if options.username
91
- "#{options.username}@#{options.host}"
92
- else
93
- options.host
94
- end
95
- end
96
-
97
- def rsync(source_dir, destination_dir)
98
-
99
- exclude_file = Tempfile.new('exclude')
100
- exclude_file.write(options.exclude.join("\n"))
101
- exclude_file.close
102
-
103
- arguments = [ "-azLKO" ]
104
-
105
- if options.ssh
106
- remote_shell_arguments = []
107
-
108
- if options.ssh.gateway
109
- remote_shell_arguments.push("ssh", get_host_for_options(options.ssh.gateway))
110
-
111
- if options.ssh.gateway.port
112
- remote_shell_arguments.push("-p", options.ssh.gateway.port)
113
- end
114
- end
115
-
116
- remote_shell_arguments.push("ssh")
117
-
118
- if options.ssh.port
119
- remote_shell_arguments.push("-p", options.ssh.port)
120
- end
121
-
122
- if options.ssh.password
123
- remote_shell_arguments.unshift("sshpass", "-p", options.ssh.password)
124
- end
125
-
126
- remote_shell_arguments.push(get_host_for_options(options.ssh))
127
-
128
- arguments.push("-e", remote_shell_arguments.join(" "))
129
- end
130
-
131
- arguments.push("--exclude-from=#{exclude_file.path}", "--delete", source_dir, destination_dir)
132
- locally_run "rsync", *arguments
133
-
134
- exclude_file.unlink
135
- end
136
- end
137
- end