rsync-deploy 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +27 -1
- data/bin/deploy +12 -4
- data/lib/deploy/environment.rb +27 -9
- data/lib/deploy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDNjODI1ZjBkOWJhMWIwZThjMjVmNjEwOGQ3NjNjYjcxNTg1MGZjZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODliZmE4MDNkOGMxMGI3ZmIwOGI3N2JlMWRjZDAzMTBlN2FmMjc0MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDFlMDZiMDIxYzg4NTc4YmZkYWY5OTczYTE2MDliYTJmZjFhMzU5Mzk0MWRj
|
10
|
+
NWM5YTU1ODQ4MTJlN2VkNWVmNzcyNDE4OTY0MzM4ZDVjYjI1MTg4YWQ3NTgx
|
11
|
+
MTc1NDgyNDY5NzI4MGM1N2RmZWQ1ZGNhYWM5Y2FkNDkzYmExYTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTRmMTBhNDY5NzI3MWJlZDQ3ZmUxYTdjZmQ4MjhjNjg3ZjgzMGJhMjkyOGM3
|
14
|
+
OGVjNzEzMjQ1NjEwMGJjYTMxM2NiMzNhZGYwODlhZmVlZDg4ODBkMmU2Njk4
|
15
|
+
NDEyZjI4ZWY4MGM5NjY4ZDVhOTIyMDFjZTc1ODgyNzdiZWUxYjc=
|
data/README.md
CHANGED
@@ -95,12 +95,38 @@ Below is a list of all available configuration options.
|
|
95
95
|
|
96
96
|
The server that the files should be deployed to.
|
97
97
|
|
98
|
+
### port
|
99
|
+
|
100
|
+
- Type: `Number`
|
101
|
+
- Default: `22`
|
102
|
+
- Required: `Yes`
|
103
|
+
|
104
|
+
The port that the connection should happen over
|
105
|
+
|
98
106
|
### user
|
99
107
|
|
100
108
|
- Type: `String`
|
101
109
|
- Default: `none`
|
102
110
|
|
103
|
-
The username to login to the server. If no username is set, your computer account username will be used.
|
111
|
+
The username to login to the server. If no username is set, your computer account username will be used.
|
112
|
+
|
113
|
+
### pass
|
114
|
+
|
115
|
+
- Type: `String`
|
116
|
+
- Default: `none`
|
117
|
+
|
118
|
+
The password to login to the server. If SSH keys aren't available, then the `pass` option will be used. If neither SSH keys nor `pass` are set, a prompt will be given.
|
119
|
+
|
120
|
+
### privateKey
|
121
|
+
|
122
|
+
- Type: `String`
|
123
|
+
- Default: `none`
|
124
|
+
|
125
|
+
The path to an alternative SSH key. This only needs to be set if your key isn't one of the following:
|
126
|
+
```
|
127
|
+
~/.ssh/id_rsa
|
128
|
+
~/.ssh/id_dsa
|
129
|
+
```
|
104
130
|
|
105
131
|
### sync
|
106
132
|
|
data/bin/deploy
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
require 'deploy'
|
4
4
|
require 'fileutils'
|
5
5
|
|
6
|
+
# TODO: Create `-r`, `--rev`, `--reverse`, `rev`, `reverse` command to download
|
7
|
+
# from the server instead of upload
|
8
|
+
# TODO: Allow pre/post-deploy tasks to be run on a per-environment basis for
|
9
|
+
# both local and remote servers. That could help some people, but not really
|
10
|
+
# needed for a while yet.
|
11
|
+
|
6
12
|
def help
|
7
13
|
%Q(
|
8
14
|
Usage: deploy [COMMAND] [ENVIRONMENTS] [OPTIONS]
|
@@ -13,9 +19,10 @@ def help
|
|
13
19
|
version Prints the siteleaf gem version
|
14
20
|
|
15
21
|
Environments:
|
16
|
-
<env>
|
22
|
+
<env> Deploys listed environments
|
17
23
|
|
18
|
-
If no commands, environments, or options are given,
|
24
|
+
If no commands, environments, or options are given,
|
25
|
+
the first environment in the config file will be deployed.
|
19
26
|
|
20
27
|
Options:
|
21
28
|
-h, --help Prints this help document
|
@@ -48,7 +55,7 @@ def install
|
|
48
55
|
File.open(Deploy::CONFIG_PATH, 'w+') do |file|
|
49
56
|
file.puts 'server_name:',' host: ""',' user: ""',' pass: ""',' path:',' local: "/"',' remote: "/public_html/"'
|
50
57
|
end
|
51
|
-
puts "Configuration file
|
58
|
+
puts "Configuration file `#{Deploy::CONFIG_PATH}` created."
|
52
59
|
else
|
53
60
|
puts "No congifuration file has been installed."
|
54
61
|
end
|
@@ -58,7 +65,7 @@ def install
|
|
58
65
|
File.open(Deploy::CONFIG_PATH, 'w+') do |file|
|
59
66
|
file.puts 'server_name:',' host: ""',' user: ""',' pass: ""',' path:',' local: "/"',' remote: "/public_html/"'
|
60
67
|
end
|
61
|
-
puts "
|
68
|
+
puts "Configuration file `#{Deploy::CONFIG_PATH}` created."
|
62
69
|
|
63
70
|
end
|
64
71
|
|
@@ -79,6 +86,7 @@ if ARGV.size > 0
|
|
79
86
|
end
|
80
87
|
end
|
81
88
|
|
89
|
+
|
82
90
|
if File.exist?(Deploy::CONFIG_PATH)
|
83
91
|
deploy = Deploy::Deployment.new
|
84
92
|
deploy.go ARGV
|
data/lib/deploy/environment.rb
CHANGED
@@ -12,12 +12,15 @@ module Deploy
|
|
12
12
|
def initialize(name, hash)
|
13
13
|
|
14
14
|
@name = name
|
15
|
-
@config = { :host => '', :user => '', :pass => '', :local => '', :remote => '' }
|
15
|
+
@config = { :host => '', :port => '', :user => '', :pass => '', :private_key => '', :local => '', :remote => '' }
|
16
16
|
@options = { :verbose => false, :sync => true }
|
17
17
|
|
18
18
|
@config[:host] = hash['host']
|
19
|
+
@config[:port] = hash['port'] || '22'
|
20
|
+
|
19
21
|
@config[:user] = hash['user'] || ''
|
20
22
|
@config[:pass] = hash['pass'] || ''
|
23
|
+
@config[:private_key] = hash['privateKey'] || ''
|
21
24
|
|
22
25
|
@config[:local] = hash['path']['local'].gsub(/\s+/, "")
|
23
26
|
@config[:remote] = hash['path']['remote'].gsub(/\s+/, "")
|
@@ -29,8 +32,9 @@ module Deploy
|
|
29
32
|
@config[:remote].insert(0,'/') unless @config[:remote].start_with?('/')
|
30
33
|
|
31
34
|
|
32
|
-
@config[:excludes] = hash['exclude']
|
35
|
+
@config[:excludes] = hash['exclude'] || Array.new
|
33
36
|
|
37
|
+
|
34
38
|
@options[:verbose] = hash['verbose'] unless hash['verbose'].nil?
|
35
39
|
@options[:sync] = hash['sync'] unless hash['sync'].nil?
|
36
40
|
|
@@ -47,7 +51,7 @@ module Deploy
|
|
47
51
|
def deploy
|
48
52
|
|
49
53
|
# Create excludes file if needed
|
50
|
-
|
54
|
+
unless @config[:excludes].empty?
|
51
55
|
tmp_exclude = Tempfile.new(['excludes','.txt'])
|
52
56
|
@config[:excludes].each do |ex|
|
53
57
|
tmp_exclude.puts ex
|
@@ -56,6 +60,12 @@ module Deploy
|
|
56
60
|
tmp_exclude.puts Deploy::CONFIG_PATH
|
57
61
|
tmp_exclude.close
|
58
62
|
end
|
63
|
+
|
64
|
+
unless @config[:pass].empty?
|
65
|
+
tmp_pass = Tempfile.new(['pass','.txt'])
|
66
|
+
tmp_pass.puts @config[:pass]
|
67
|
+
tmp_pass.close
|
68
|
+
end
|
59
69
|
|
60
70
|
rsync_cmd = 'rsync -a' # Always keep permissions
|
61
71
|
rsync_cmd += 'v' if @options[:verbose] # Verbose if requested
|
@@ -64,7 +74,14 @@ module Deploy
|
|
64
74
|
rsync_cmd += ' --progress' # Always show progress
|
65
75
|
rsync_cmd += ' --force --delete' unless @options[:sync] == false # Sync unless explicitly requested
|
66
76
|
rsync_cmd += " --exclude-from=#{tmp_exclude.path}" unless @config[:excludes].empty? # Include exclude file if it exists
|
67
|
-
rsync_cmd += " -
|
77
|
+
rsync_cmd += " --password-file=#{tmp_pass.path}" unless @config[:pass].empty? # Include password file if it exists
|
78
|
+
rsync_cmd += " -e \"ssh "
|
79
|
+
|
80
|
+
if(@config[:pass].empty? and @config[:private_key].empty?)
|
81
|
+
rsync_cmd += " -i #{@config[:private_key]} " # Include a custom private key if requested
|
82
|
+
end
|
83
|
+
|
84
|
+
rsync_cmd += "-p#{@config[:port]}\"" # Choose port if specified
|
68
85
|
|
69
86
|
rsync_cmd += " " + `pwd`.gsub(/\s+/, "") + "#{@config[:local]}" # The local path from the current directory
|
70
87
|
|
@@ -77,8 +94,9 @@ module Deploy
|
|
77
94
|
# puts rsync_cmd
|
78
95
|
system(rsync_cmd)
|
79
96
|
|
80
|
-
# Remove excludes file if needed
|
81
|
-
tmp_exclude.unlink
|
97
|
+
# Remove excludes/pass file if needed
|
98
|
+
tmp_exclude.unlink unless @config[:excludes].empty?
|
99
|
+
tmp_pass.unlink unless @config[:pass].empty?
|
82
100
|
|
83
101
|
end
|
84
102
|
|
@@ -87,12 +105,12 @@ module Deploy
|
|
87
105
|
def validate
|
88
106
|
|
89
107
|
# Fail without hostname (user/password are optional)
|
90
|
-
|
108
|
+
(puts "Error: no hostname set for `#{@name}`"; exit;) if @config[:host].empty?
|
91
109
|
|
92
110
|
# Fail if local/remote paths not set (because they should be in initialize
|
93
111
|
# even if they're not set in the yml config file.
|
94
|
-
|
95
|
-
|
112
|
+
(puts "Error: no local path set for `#{@name}`"; exit;) if @config[:local].empty?
|
113
|
+
(puts "Error: no remote path set for `#{@name}`"; exit;) if @config[:remote].empty?
|
96
114
|
|
97
115
|
end
|
98
116
|
|
data/lib/deploy/version.rb
CHANGED