vagrant-windows-guest-nfs 0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 730afc120f92e95b3933bafc9cbe19a4fec17354
4
+ data.tar.gz: f9842a811bdd03ade8015343205ee2f0bd088d35
5
+ SHA512:
6
+ metadata.gz: dc2f4ff2e46efc7281bcc32be758b0641b8149723c387f303b29dfd43e9b257efe485c8011da297ccd52cd374a46eea237efb171f7da311747aac7c07cef7b84
7
+ data.tar.gz: 116f6ced4062f2dabdcf2afdd597b48930fd6200df0c095bc3fb3093f09901b7b8858fd20535f96de8bdb22e77f421acfb066d3b2028ea5e75090a1428489e4a
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /exec/
10
+ /*.gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.4
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ group :development do
6
+ gem "bundler", "~> 1.16"
7
+ gem "rake", "~> 10.0"
8
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
9
+ end
10
+
11
+ group :plugins do
12
+ gem "vagrant-windows-guest-nfs", path: "."
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,112 @@
1
+ GIT
2
+ remote: https://github.com/mitchellh/vagrant.git
3
+ revision: 8e63cf84bc6db7782e609935fd664e07de12b483
4
+ specs:
5
+ vagrant (2.0.1)
6
+ childprocess (~> 0.6.0)
7
+ erubis (~> 2.7.0)
8
+ hashicorp-checkpoint (~> 0.1.1)
9
+ i18n (>= 0.6.0, <= 0.8.0)
10
+ listen (~> 3.1.5)
11
+ log4r (~> 1.1.9, < 1.1.11)
12
+ net-scp (~> 1.2.0)
13
+ net-sftp (~> 2.1)
14
+ net-ssh (~> 4.1.0)
15
+ rb-kqueue (~> 0.2.0)
16
+ rest-client (>= 1.6.0, < 3.0)
17
+ ruby_dep (<= 1.3.1)
18
+ wdm (~> 0.1.0)
19
+ winrm (~> 2.1)
20
+ winrm-elevated (~> 1.1)
21
+ winrm-fs (~> 1.0)
22
+
23
+ PATH
24
+ remote: .
25
+ specs:
26
+ vagrant-windows-guest-nfs (0.1)
27
+
28
+ GEM
29
+ remote: https://rubygems.org/
30
+ specs:
31
+ builder (3.2.3)
32
+ childprocess (0.6.3)
33
+ ffi (~> 1.0, >= 1.0.11)
34
+ domain_name (0.5.20170404)
35
+ unf (>= 0.0.5, < 1.0.0)
36
+ erubis (2.7.0)
37
+ ffi (1.9.18)
38
+ gssapi (1.2.0)
39
+ ffi (>= 1.0.1)
40
+ gyoku (1.3.1)
41
+ builder (>= 2.1.2)
42
+ hashicorp-checkpoint (0.1.4)
43
+ http-cookie (1.0.3)
44
+ domain_name (~> 0.5)
45
+ httpclient (2.8.3)
46
+ i18n (0.8.0)
47
+ listen (3.1.5)
48
+ rb-fsevent (~> 0.9, >= 0.9.4)
49
+ rb-inotify (~> 0.9, >= 0.9.7)
50
+ ruby_dep (~> 1.2)
51
+ little-plugger (1.1.4)
52
+ log4r (1.1.10)
53
+ logging (2.2.2)
54
+ little-plugger (~> 1.1)
55
+ multi_json (~> 1.10)
56
+ mime-types (3.1)
57
+ mime-types-data (~> 3.2015)
58
+ mime-types-data (3.2016.0521)
59
+ multi_json (1.12.2)
60
+ net-scp (1.2.1)
61
+ net-ssh (>= 2.6.5)
62
+ net-sftp (2.1.2)
63
+ net-ssh (>= 2.6.5)
64
+ net-ssh (4.1.0)
65
+ netrc (0.11.0)
66
+ nori (2.6.0)
67
+ rake (10.5.0)
68
+ rb-fsevent (0.10.2)
69
+ rb-inotify (0.9.10)
70
+ ffi (>= 0.5.0, < 2)
71
+ rb-kqueue (0.2.5)
72
+ ffi (>= 0.5.0)
73
+ rest-client (2.0.2)
74
+ http-cookie (>= 1.0.2, < 2.0)
75
+ mime-types (>= 1.16, < 4.0)
76
+ netrc (~> 0.8)
77
+ ruby_dep (1.3.1)
78
+ rubyntlm (0.6.2)
79
+ rubyzip (1.2.1)
80
+ unf (0.1.4)
81
+ unf_ext
82
+ unf_ext (0.0.7.4)
83
+ wdm (0.1.1)
84
+ winrm (2.2.3)
85
+ builder (>= 2.1.2)
86
+ erubis (~> 2.7)
87
+ gssapi (~> 1.2)
88
+ gyoku (~> 1.0)
89
+ httpclient (~> 2.2, >= 2.2.0.2)
90
+ logging (>= 1.6.1, < 3.0)
91
+ nori (~> 2.0)
92
+ rubyntlm (~> 0.6.0, >= 0.6.1)
93
+ winrm-elevated (1.1.0)
94
+ winrm (~> 2.0)
95
+ winrm-fs (~> 1.0)
96
+ winrm-fs (1.1.0)
97
+ erubis (~> 2.7)
98
+ logging (>= 1.6.1, < 3.0)
99
+ rubyzip (~> 1.1)
100
+ winrm (~> 2.0)
101
+
102
+ PLATFORMS
103
+ ruby
104
+
105
+ DEPENDENCIES
106
+ bundler (~> 1.16)
107
+ rake (~> 10.0)
108
+ vagrant!
109
+ vagrant-windows-guest-nfs!
110
+
111
+ BUNDLED WITH
112
+ 1.16.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Alejandro Ojeda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # vagrant-windows-guest-nfs
2
+
3
+ This plugin enables usage of NFS shared folders in Windows guests.
4
+
5
+ Useful for libvirt users.
6
+
7
+ ## Installation
8
+
9
+ ```
10
+ vagrant plugin install vagrant-windows-guest-nfs
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ NFS must already be installed in the guest, otherwise it won't work.
16
+
17
+ ## Contributing
18
+
19
+ Bug reports and pull requests are welcome on GitHub at https://github.com/alexoj/vagrant-windows-guest-nfs.
20
+
21
+ ## License
22
+
23
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vagrant_windows_guest_nfs"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require "vagrant-windows-guest-nfs/version"
2
+ require "vagrant-windows-guest-nfs/plugin"
@@ -0,0 +1,54 @@
1
+ require "vagrant/util/template_renderer"
2
+ require "base64"
3
+
4
+ module VagrantWindowsGuestNfs
5
+ class MountNfsFolder
6
+ def self.nfs_client_installed(machine)
7
+ machine.communicate.test("sc query nfsclnt")
8
+ end
9
+
10
+ def self.mount_nfs_folder(machine, ip, folders)
11
+ setup_guest_anon_uid(machine)
12
+
13
+ folders.each do |name, opts|
14
+ guest_path = Shellwords.escape(opts[:guestpath])
15
+ host_path = Shellwords.escape(opts[:hostpath].sub(/^\//, '').gsub('/', "\\"))
16
+
17
+ path = File.expand_path("../scripts/mount_nfs_folder.ps1", __FILE__)
18
+ script = Vagrant::Util::TemplateRenderer.render(path, options: {
19
+ ip: ip,
20
+ guest_path: guest_path,
21
+ host_path: host_path,
22
+ })
23
+ run_script(machine, script)
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def self.setup_guest_anon_uid(machine)
30
+ path = File.expand_path("../scripts/change_anon_uid.ps1", __FILE__)
31
+ script = Vagrant::Util::TemplateRenderer.render(path, options: {
32
+ uid: Process.uid,
33
+ gid: Process.gid,
34
+ })
35
+ run_script(machine, script)
36
+ end
37
+
38
+ def self.run_script(machine, script)
39
+ if machine.config.vm.communicator == :winrm || machine.config.vm.communicator == :winssh
40
+ machine.communicate.execute(script, shell: :powershell)
41
+ else
42
+ # Convert script to double byte unicode string then base64 encode
43
+ # just like PowerShell -EncodedCommand expects.
44
+ # Suppress the progress stream from leaking to stderr.
45
+ wrapped_encoded_command = Base64.strict_encode64(
46
+ "$ProgressPreference='SilentlyContinue'; #{script}; exit $LASTEXITCODE".encode('UTF-16LE', 'UTF-8'))
47
+ # Execute encoded PowerShell script via OpenSSH shell
48
+ machine.communicate.execute("powershell.exe -noprofile -executionpolicy bypass " +
49
+ "-encodedcommand '#{wrapped_encoded_command}'", shell: "sh")
50
+ end
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,15 @@
1
+ module VagrantWindowsGuestNfs
2
+ class VagrantWindowsGuestNfsPlugin < Vagrant.plugin("2")
3
+ name "vagrant_windows_guest_nfs"
4
+
5
+ guest_capability(:windows, :nfs_client_installed) do
6
+ require_relative 'mount_nfs_folder'
7
+ MountNfsFolder
8
+ end
9
+
10
+ guest_capability(:windows, :mount_nfs_folder) do
11
+ require_relative 'mount_nfs_folder'
12
+ MountNfsFolder
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ $anonUid = [int]"<%= options[:uid] %>"
2
+ $anonGid = [int]"<%= options[:gid] %>"
3
+
4
+ $key = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default"
5
+
6
+ $curAnonUid = [int](Get-ItemProperty -Path $key -Name "AnonymousUid")."AnonymousUid"
7
+ $curAnonGid = [int](Get-ItemProperty -Path $key -Name "AnonymousGid")."AnonymousGid"
8
+
9
+ if (($anonUid -ne $curAnonUid) -or ($anonGid -ne $curAnonGid)) {
10
+ Set-ItemProperty -Path $key -Name "AnonymousUid" -Value $anonUid
11
+ Set-ItemProperty -Path $key -Name "AnonymousGid" -Value $anonGid
12
+
13
+ & nfsadmin client stop
14
+ & nfsadmin client start
15
+ }
@@ -0,0 +1,40 @@
1
+ function Test-ReparsePoint([string]$path) {
2
+ $file = Get-Item $path -Force -ea 0
3
+ return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
4
+ }
5
+
6
+ $guestPath = [System.IO.Path]::GetFullPath("<%= options[:guest_path] %>")
7
+ $hostPath = "<%= options[:host_path] %>"
8
+ $ip = "<%= options[:ip] %>"
9
+
10
+ if ((Test-Path "$guestPath") -and (Test-ReparsePoint "$guestPath"))
11
+ {
12
+ Write-Debug "Junction already exists, so I will delete it"
13
+ cmd /c rd "$guestPath"
14
+
15
+ if ($LASTEXITCODE -ne 0)
16
+ {
17
+ Write-Error "Failed to delete symbolic link at $guestPath"
18
+ exit 1
19
+ }
20
+ }
21
+ elseif (Test-Path $guestPath)
22
+ {
23
+ Write-Error "Mount point already exists and is not a symbolic link"
24
+ exit 1
25
+ }
26
+
27
+ $baseDirectory = [System.IO.Path]::GetDirectoryName($guestPath)
28
+
29
+ if (-not (Test-Path $baseDirectory))
30
+ {
31
+ Write-Debug "Creating parent directory for mount point $baseDirectory"
32
+ New-Item $baseDirectory -Type Directory -Force | Out-Null
33
+ }
34
+
35
+ cmd /c mklink /D "$guestPath" "\\${ip}\${hostPath}" | Out-Null
36
+ if ($LASTEXITCODE -ne 0)
37
+ {
38
+ Write-Error "Failed to create symbolic link"
39
+ exit 1
40
+ }
@@ -0,0 +1,3 @@
1
+ module VagrantWindowsGuestNfs
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "vagrant-windows-guest-nfs/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "vagrant-windows-guest-nfs"
7
+ spec.version = VagrantWindowsGuestNfs::VERSION
8
+ spec.authors = ["Alejandro Ojeda"]
9
+ spec.email = ["alex@x3y.org"]
10
+
11
+ spec.summary = %q{Vagrant plugin that mounts NFS shared folders in windows guests.}
12
+ spec.homepage = "https://github.com/alexoj/vagrant-windows-guest-nfs"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-windows-guest-nfs
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Alejandro Ojeda
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - alex@x3y.org
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".ruby-version"
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bin/console
28
+ - bin/setup
29
+ - lib/vagrant-windows-guest-nfs.rb
30
+ - lib/vagrant-windows-guest-nfs/mount_nfs_folder.rb
31
+ - lib/vagrant-windows-guest-nfs/plugin.rb
32
+ - lib/vagrant-windows-guest-nfs/scripts/change_anon_uid.ps1.erb
33
+ - lib/vagrant-windows-guest-nfs/scripts/mount_nfs_folder.ps1.erb
34
+ - lib/vagrant-windows-guest-nfs/version.rb
35
+ - vagrant-windows-guest-nfs.gemspec
36
+ homepage: https://github.com/alexoj/vagrant-windows-guest-nfs
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.5.2
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Vagrant plugin that mounts NFS shared folders in windows guests.
60
+ test_files: []