vagrant-rsync 0.1.1 → 0.2.0

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.
Files changed (5) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +2 -0
  3. data/lib/command.rb +55 -3
  4. data/lib/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGNmMGI2Mjc4NTBmN2ExNjc2YjBkMDFjZjliZjJhODgxYmFkYjBiOA==
4
+ NjRjMzc4ODNmMmQ4ZDRiNTk0YWNiNTE3YmYyMjhjYTE1YzVlZGE0OQ==
5
5
  data.tar.gz: !binary |-
6
- NDhjYjVhY2EyMjgwZWE5ODEzOWQxYzBjNjYzMjJhZGExZWMxY2RmNA==
6
+ NGU5MGE1NjE5NmZlOWViMDI5NzRhZGQxYWEwMjQxMThmZmQ5OTVlZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDNiMjgxNTc2M2U0NzgzMGM5ZjNhZTRlYmY4MWMyN2ZlMWNmODE2OTljYzk0
10
- YTIxOWQ0MWIwOWZlY2QyNTM1NDBkNmJlMDE0NTg3ZWQ4ZTlmNTJhNTIyMTg3
11
- OTA3Y2JiYjBmMDUxZmFlNDFhZDdmZjc1MjEyOTZjZTIxYjdlZjg=
9
+ MzJmNDNmZWRkYjBmMjU5ZDM2ZjJhODM4NmNlYTI1YThhYWQ1Yjk4NzA4NmNl
10
+ MWExNTg5NmVlY2I4MTkzYzkyYzMyMmU3NGM0YWE1OWM5YWYyNTNlMWZmYTlj
11
+ MGQ0MmMyNDNkNzlmOGViN2Y3YjNhM2M1MjU3ZDQ5ZWI5YTU0ZTg=
12
12
  data.tar.gz: !binary |-
13
- NGUwZTNkNjk3N2Y2YzI2Nzk5ODdmNzE4OTg5ZWFmMTNiMTdhMjE5ZWNiYzQ4
14
- ZDFhYTQzNWU4MmQ2NDM4MTE5MDk2MmM4MGY2NDQyNDQ3ODQ3YzE2NGFkMDg3
15
- ZWJiMGNhODU5NTU3YmRiMmZlZGFlYzkzNWQ4OWFkY2YxMjU2MGU=
13
+ YjliZmQwOGU2M2Y1YWRiYzE0Y2Q2N2U5MWExZWFjZTE2OTZjNGUxNDBlM2Vl
14
+ NmZmNzcxNWVjZjY5OTdiNDY4YTE0NGEwYWVmMTJhYTI5ZGVmMDAxZWYxNzRk
15
+ N2NhOTA5YjJmNjUzOGJkNDcyMzBiYTU1NGY0ZjI0M2FjOTc0ZmU=
data/README.md CHANGED
@@ -8,6 +8,7 @@ Based off of [Vagrant-Sync](https://github.com/calavera/vagrant-sync)
8
8
  ## Features
9
9
  * automatically detects all shared folders, on all named machines
10
10
  * syncs em up.
11
+ * install rsync automatically on a variety of linux based guests. (turn off with --no-install)
11
12
 
12
13
  ## Usage
13
14
 
@@ -24,6 +25,7 @@ Note: This plugin is meant for interacting with guests that are not running on y
24
25
  I have no idea what will happen if you are sharing with NFS or virtualbox shared folders.
25
26
  It might destroy all your data and turn your co-workers into angry badgers. Be forewarned.
26
27
 
28
+ If you'd like me to add new guests to the rsync auto-install, send me the command to install rsync, and I'll make it happen.
27
29
 
28
30
  Can be mixed in with Guard or kicker or what-have-you to rsync whenever the host filesystem changes.
29
31
 
data/lib/command.rb CHANGED
@@ -1,27 +1,76 @@
1
1
  require 'optparse'
2
+ require 'pp'
2
3
  module VagrantPlugins
3
4
  module CommandRSYNC
4
5
  class Command < Vagrant.plugin("2", :command)
6
+
7
+ class RsyncNotAvailableError < Vagrant::Errors::VagrantError
8
+ error_namespace("vagrant.plugin.vagrant-rsync")
9
+ end
10
+
11
+ def verify_rsync(vm)
12
+ begin
13
+ vm.communicate.execute("rsync --version")
14
+ rescue Exception => e
15
+ @env.ui.say(:info, "rsync not found, installing rsync now. disable this with --no-install")
16
+ # should notify people we are installing rsync here.
17
+ case vm.guest.name
18
+ when :debian, :ubuntu
19
+ vm.communicate.sudo("apt-get update")
20
+ vm.communicate.sudo("apt-get install rsync")
21
+ when :fedora, :centos, :redhat
22
+ vm.communicate.sudo("yum install rsync")
23
+ when :suse
24
+ vm.communicate.sudo("yast2 -i rsync")
25
+ when :gentoo
26
+ vm.communicate.sudo("emerge rsync")
27
+ when :arch
28
+ vm.communicate.sudo("pacman -s rsync")
29
+ # when :solaris
30
+ # vm.communicate.sudo("pkg install rsync")
31
+ # when :freebsd
32
+ # vm.communicate.sudo("pkg_add -r rsync")
33
+ else
34
+ raise RsyncNotAvailableError
35
+ end
36
+ end
37
+ end
38
+
5
39
  def execute
6
- options = {}
40
+ options = { :install_rsync => true,
41
+ :verbose => false}
7
42
 
8
43
  opts = OptionParser.new do |opt|
9
44
  opt.banner = "Usage: vagrant rsync [vm-name]"
10
- opt.on('--verbose') do |v|
45
+ opt.on("-n","--no-install", "do not attempt to install rysnc if not found") do |v|
46
+ options[:install_rsync] = false
47
+ end
48
+ opt.on('-v','--verbose',"Run verbosely") do |v|
11
49
  options[:verbose] = true
12
50
  end
51
+ opts.on( '-h', '--help', 'Display this screen' ) do
52
+ puts opts
53
+ exit
54
+ end
13
55
  end
14
56
 
15
57
  argv = parse_options(opts)
16
58
  unless argv
17
59
  argv=["default"]
18
60
  end
61
+
19
62
  with_target_vms(argv) do |vm|
20
63
  raise Vagrant::Errors::VMNotCreatedError if vm.state.id == :not_created
21
64
  raise Vagrant::Errors::VMInaccessible if vm.state.id == :inaccessible
22
65
  end
23
66
 
24
67
  with_target_vms(argv) do |vm|
68
+
69
+ if options[:install_rsync]
70
+ @env.ui.say(:info,"checking if rsync exists on host")
71
+ verify_rsync(vm)
72
+ end
73
+
25
74
  vm.config.vm.synced_folders.each do |id, data|
26
75
  next if data[:nfs]
27
76
  hostpath = File.expand_path(data[:hostpath], vm.env.root_path)
@@ -41,10 +90,13 @@ module VagrantPlugins
41
90
 
42
91
 
43
92
  if options[:verbose]
44
- puts command.join(" ")
93
+ ## should the vagrant way of outputting text
94
+ @env.ui.say(:info,command.join(" "))
45
95
  end
46
96
 
47
97
  r = Vagrant::Util::Subprocess.execute(*command)
98
+ @env.ui.say(:info, "done") if options[:verbose]
99
+ pp r.inspect
48
100
  if r.exit_code != 0
49
101
  raise Errors::RsyncError,
50
102
  :guestpath => guestpath,
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module RSYNC
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-rsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Cromie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-09 00:00:00.000000000 Z
11
+ date: 2013-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement