vagrant-notify-forwarder2 0.6.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b21fead0d40d7034ebba97b9c0a9346529d6c42ac0af6a66d385a46e708b4e6f
4
+ data.tar.gz: 6357753f5d95b8fbc7cbe3696e9675f9d9ff3c87daedcd7e2b2d16ffc953479c
5
+ SHA512:
6
+ metadata.gz: 2e6ff2c8f69f864c1c1618443dbb1c7f2a393731e9e28a901a207d32e820b409f1ce3d71b0f5954eaffac69bcae1b192201c4fc358eabc52bf60cc6a98f7866b
7
+ data.tar.gz: 3b648b54ba6f178e97bc9c86fc028f5ef9fada5cb895897688572360e4a45a555418e4da3fb3b98406c58998965d3b99ba014b5a167fc27fe4aa2ba9b7887ae0
data/.gitignore ADDED
@@ -0,0 +1,28 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ *.bundle
18
+ *.so
19
+ *.o
20
+ *.a
21
+ mkmf.log
22
+ Vagrantfile
23
+ /.vagrant
24
+ Gemfile.lock
25
+ .idea
26
+ .history
27
+ vendor
28
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "rake"
5
+ gem "vagrant", git: "https://github.com/hashicorp/vagrant.git"
6
+ end
7
+
8
+ group :plugins do
9
+ gem "vagrant-notify-forwarder2", path: "."
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 mhallin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # Vagrant file system notification forwarder plugin
2
+
3
+ A vagrant plugin that uses [notify-forwarder](https://github.com/mhallin/notify-forwarder) to
4
+ forward file system events from the host to the guest automatically on all shared folders.
5
+
6
+ This is useful for auto reloading file systems that rebuild when files change. Normally, they have
7
+ to use CPU intensive polling when watching shared folders. This plugin makes them able to use
8
+ inotify or similar for improved performance and reduced CPU usage.
9
+
10
+ ## Installation and usage
11
+
12
+ ```terminal
13
+ $ vagrant plugin install vagrant-notify-forwarder
14
+ $ vagrant reload
15
+ ```
16
+
17
+ By default, this sets up UDP port 29324 for port forwarding. If you're already using this port, or
18
+ if you want to change it, add the following line to your `Vagrantfile`:
19
+
20
+ ```ruby
21
+ config.notify_forwarder.port = 22020 # Or your port number
22
+ ```
23
+
24
+ The server and guest binaries will be automatically downloaded from the notify-forwarder repo's
25
+ releases and verified with SHA256.
26
+
27
+ ### Overriding binary sources
28
+
29
+ The plugin ships with a default map of download URLs and SHA256 checksums for each supported
30
+ `[os, hardware]` combination. You can override or extend the map via
31
+ `config.notify_forwarder.binaries`:
32
+
33
+ ```ruby
34
+ config.notify_forwarder.binaries = {
35
+ [:darwin, :arm64] => {
36
+ url: "https://example.com/notify-forwarder-osx-arm64",
37
+ sha256: "deadbeef..."
38
+ },
39
+ [:linux, :riscv64] => [
40
+ "https://example.com/notify-forwarder-linux-riscv64",
41
+ "cafebabe..."
42
+ ]
43
+ }
44
+ ```
45
+
46
+ You may supply each entry either as an array `[url, sha256]` or a hash with `:url`/`:sha256` keys.
47
+ Entries you omit continue using the built-in defaults.
48
+
49
+ Environment variables are expanded in URLs, so you can point to local binaries using values like
50
+ `$HOME`. For example:
51
+
52
+ ```ruby
53
+ config.notify_forwarder.binaries = {
54
+ [:darwin, :arm64] => [
55
+ "file://$HOME/dev/notify-forwarder/osx-arm64",
56
+ "deadbeef..."
57
+ ]
58
+ }
59
+ ```
60
+
61
+ Relative and `file://` URLs are also expanded to absolute paths on the host before download.
62
+
63
+ ## Development
64
+
65
+ Use Bundler and the project `Rakefile` to keep all tooling local to the repository.
66
+
67
+ 1. Install dependencies into `vendor/bundle/`:
68
+
69
+ ```terminal
70
+ rake dev:bundle
71
+ ```
72
+
73
+ The task sets `bundle config set --local path 'vendor/bundle'` and installs the gems. If you prefer to run it manually the first time, execute `bundle install --path vendor/bundle`.
74
+
75
+ 2. Iterate on the plugin and rebuild when you want a packaged gem:
76
+
77
+ ```terminal
78
+ bundle exec rake dev:build
79
+ ```
80
+
81
+ 3. (Optional) Install the packaged gem into your user Vagrant plugin directory for testing the exact artifact:
82
+
83
+ ```terminal
84
+ bundle exec rake dev:install
85
+ ```
86
+
87
+ 4. Launch or reload your Vagrant environment using the local plugin path declared in `Gemfile`:
88
+
89
+ ```terminal
90
+ bundle exec rake dev:up
91
+ bundle exec rake dev:reload
92
+ ```
93
+
94
+ All commands run entirely within the repository—no global gems or system Vagrant plugins are modified. Remove `vendor/bundle/` if you need a clean slate before reinstalling.
95
+
96
+ ### Permissions
97
+
98
+ The client in the guest OS will run as root by default, assuming passwordless `sudo` works. If this
99
+ does *not* work, you can disable privilege escalation in your `Vagrantfile`:
100
+
101
+ ```ruby
102
+ config.notify_forwarder.run_as_root = false
103
+ ```
104
+
105
+ ## Supported operating systems
106
+
107
+ To conserve size and dependencies, the plugin downloads binaries for supported platforms. This
108
+ plugin supports the same host/guest platforms as `notify-forwarder` itself:
109
+
110
+ * FreeBSD 64 bit as guest,
111
+ * Linux 64 bit as host and guest, and
112
+ * Mac OS X 64 bit as host and guest.
113
+
114
+ If you're running an unsupported host or guest and want to disable this plugin for a specific
115
+ machine, add the following line to your `Vagrantfile`:
116
+
117
+ ```ruby
118
+ config.notify_forwarder.enable = false
119
+ ```
120
+
121
+ ## Contributors
122
+
123
+ * [CharlieC3](https://github.com/CharlieC3)
124
+ * [hedinfaok](https://github.com/hedinfaok)
125
+ * [seff](https://github.com/seff)
126
+ * [christhomas](https://github.com/christhomas)
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'bundler/gem_tasks'
3
+
4
+ $stdout.sync = true
5
+ $stderr.sync = true
6
+
7
+ # Change to the directory of this file.
8
+ Dir.chdir(File.expand_path("../", __FILE__))
9
+
10
+ GEMSPEC = Gem::Specification.load('vagrant-notify-forwarder.gemspec')
11
+ raise 'Unable to load vagrant-notify-forwarder.gemspec' unless GEMSPEC
12
+ GEM_PACKAGE = File.join('pkg', "#{GEMSPEC.name}-#{GEMSPEC.version}.gem")
13
+
14
+ namespace :dev do
15
+ desc 'Install gems locally under vendor/bundle'
16
+ task :bundle do
17
+ sh "bundle config set --local path 'vendor/bundle'"
18
+ sh "bundle install --path 'vendor/bundle'"
19
+ end
20
+
21
+ desc 'Build the plugin gem into pkg/'
22
+ task :build => :bundle do
23
+ Rake::Task['build'].reenable
24
+ Rake::Task['build'].invoke
25
+ end
26
+
27
+ desc 'Install the freshly built gem into your Vagrant plugins'
28
+ task :install => :build do
29
+ sh "vagrant plugin install ./#{GEM_PACKAGE}"
30
+ end
31
+
32
+ desc 'Run vagrant up using the bundled environment and local plugin path'
33
+ task :up => :bundle do
34
+ sh 'bundle exec vagrant up'
35
+ end
36
+
37
+ desc 'Reload the running Vagrant environment via Bundler'
38
+ task :reload => :bundle do
39
+ sh 'bundle exec vagrant reload'
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ module VagrantPlugins
2
+ module VagrantNotifyForwarder
3
+ module Action
4
+ class CheckBootState
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ return unless env[:machine].config.notify_forwarder.enable
11
+ $BOOT_SAVED = env[:machine].state.id == :saved
12
+
13
+ @app.call env
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,59 @@
1
+ require 'vagrant-notify-forwarder/utils'
2
+
3
+ module VagrantPlugins
4
+ module VagrantNotifyForwarder
5
+ module Action
6
+ class StartClientForwarder
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def ensure_binary_downloaded(env)
12
+ os = :unsupported
13
+ hardware = :unsupported
14
+
15
+ env[:machine].communicate.execute('uname -s') do |type, data|
16
+ env[:ui].info "Notify-forwarder: Detected client operating system: #{data}"
17
+ os = Utils.parse_os_name data if type == :stdout
18
+ end
19
+
20
+ env[:machine].communicate.execute('uname -m') do |type, data|
21
+ env[:ui].info "Notify-forwarder: Detected client hardware: #{data}"
22
+ hardware = Utils.parse_hardware_name data if type == :stdout
23
+ end
24
+
25
+ env[:ui].error "Notify-forwarder: Unsupported client operating system (detected: #{os})" if os == :unsupported
26
+ env[:ui].error "Notify-forwarder: Unsupported client hardware (detected: #{hardware})" if hardware == :unsupported
27
+
28
+ if os != :unsupported and hardware != :unsupported
29
+ Utils.ensure_binary_downloaded env, os, hardware
30
+ end
31
+ end
32
+
33
+ def call(env)
34
+ @app.call env
35
+
36
+ return if $BOOT_SAVED
37
+
38
+ return unless env[:machine].config.notify_forwarder.enable
39
+
40
+ path = ensure_binary_downloaded env
41
+ return unless path
42
+
43
+ port = env[:machine].config.notify_forwarder.port
44
+
45
+ start_command = "nohup /tmp/notify-forwarder receive -p #{port} &"
46
+
47
+ if env[:machine].config.notify_forwarder.run_as_root
48
+ start_command = "sudo #{start_command}"
49
+ end
50
+
51
+ env[:machine].communicate.upload(path, "/tmp/notify-forwarder")
52
+ env[:ui].output("Starting notify-forwarder ...")
53
+ env[:machine].communicate.execute(start_command)
54
+ env[:ui].detail("Notify-forwarder: guest listening for file change notifications on 0.0.0.0:#{port}.")
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,61 @@
1
+ require 'vagrant-notify-forwarder/utils'
2
+
3
+ module VagrantPlugins
4
+ module VagrantNotifyForwarder
5
+ module Action
6
+ class StartHostForwarder
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def ensure_binary_downloaded(env)
12
+ os = Utils.parse_os_name `uname -s`
13
+ hardware = Utils.parse_hardware_name `uname -m`
14
+
15
+ env[:ui].error "Notify-forwarder: Unsupported host operating system (detected: #{os})" if os == :unsupported
16
+ env[:ui].error "Notify-forwarder: Unsupported host hardware (detected: #{hardware})" if hardware == :unsupported
17
+
18
+ if os != :unsupported and hardware != :unsupported
19
+ Utils.ensure_binary_downloaded env, os, hardware
20
+ end
21
+ end
22
+
23
+ def start_watcher(env, command)
24
+ pid = Process.spawn command
25
+ Process.detach(pid)
26
+
27
+ pidfile = Utils.host_pidfile env
28
+ pidfile.open('a+') do |f|
29
+ f.write("#{pid}\n")
30
+ end
31
+ end
32
+
33
+ def call(env)
34
+ if env[:machine].config.notify_forwarder.enable
35
+ port = env[:machine].config.notify_forwarder.port
36
+ env[:machine].config.vm.network :forwarded_port, host: port, guest: port, protocol: 'udp'
37
+ end
38
+
39
+ @app.call env
40
+
41
+ if env[:machine].config.notify_forwarder.enable
42
+ path = ensure_binary_downloaded env
43
+ return unless path
44
+
45
+ env[:machine].config.vm.synced_folders.each do |id, options|
46
+ unless options[:disabled]
47
+ hostpath = File.expand_path(options[:hostpath], env[:root_path])
48
+ guestpath = options[:guestpath]
49
+
50
+ args = "watch -c 127.0.0.1:#{port} #{hostpath} #{guestpath}"
51
+ start_watcher env, "#{path} #{args}"
52
+ env[:ui].detail("Notify-forwarder: host sending file change notifications to 127.0.0.1:#{port}")
53
+ env[:ui].detail("Notify-forwarder: host forwarding notifications on #{hostpath} to #{guestpath}")
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,34 @@
1
+ require 'vagrant-notify-forwarder/utils'
2
+
3
+ module VagrantPlugins
4
+ module VagrantNotifyForwarder
5
+ module Action
6
+ class StopHostForwarder
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ @app.call env
13
+
14
+ return unless env[:machine].config.notify_forwarder.enable
15
+
16
+ pidfile = Utils.host_pidfile env
17
+
18
+ if File.exist? pidfile
19
+ pidfile.open('r') do |f|
20
+ f.readlines.each do |process|
21
+ pid = process.to_i
22
+ begin
23
+ Process.kill 'TERM', pid
24
+ rescue Errno::ESRCH
25
+ end
26
+ end
27
+ pidfile.delete
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,91 @@
1
+ module VagrantPlugins
2
+ module VagrantNotifyForwarder
3
+ class Config < Vagrant.plugin(2, :config)
4
+ attr_accessor :port
5
+ attr_accessor :enable
6
+ attr_accessor :run_as_root
7
+ attr_accessor :binaries
8
+
9
+ DEFAULT_BINARIES = {
10
+ [:linux, :x86_64] => [
11
+ 'https://github.com/christhomas/notify-forwarder/releases/download/v1.0.0/notify-forwarder-linux-x86_64.tar.gz',
12
+ 'cb595d193dea7608feabc9a8a87123076b96762ef1f956e06d3ae3ecef7a2424'
13
+ ],
14
+ [:linux, :arm64] => [
15
+ 'https://github.com/christhomas/notify-forwarder/releases/download/v1.0.0/notify-forwarder-linux-arm64.tar.gz',
16
+ '7561bc849fda68e2d55e43bd49e5b36fe652ae00695e29a540d2cf621269c49c'
17
+ ],
18
+ [:darwin, :x86_64] => [
19
+ 'https://github.com/christhomas/notify-forwarder/releases/download/v1.0.0/notify-forwarder-darwin-x86_64.tar.gz',
20
+ 'f9ff18eee78c6f2eef4bd249335ca76ef02a54481e011ae5b79066b34f99aa70'
21
+ ],
22
+ [:darwin, :arm64] => [
23
+ 'https://github.com/christhomas/notify-forwarder/releases/download/v1.0.0/notify-forwarder-darwin-arm64.tar.gz',
24
+ '0b12e048b7d37fa4ac0e990df9c0aeca0171468c82b6f2181ebf531b018a01e6'
25
+ ],
26
+ }.freeze
27
+
28
+ def initialize
29
+ @port = UNSET_VALUE
30
+ @enable = UNSET_VALUE
31
+ @run_as_root = UNSET_VALUE
32
+ @binaries = UNSET_VALUE
33
+ end
34
+
35
+ def finalize!
36
+ @port = 29324 if @port == UNSET_VALUE
37
+ @enable = true if @enable == UNSET_VALUE
38
+ @run_as_root = true if @run_as_root == UNSET_VALUE
39
+ @binaries = prepare_binaries(@binaries)
40
+ end
41
+
42
+ private
43
+
44
+ def prepare_binaries(value)
45
+ defaults = DEFAULT_BINARIES.transform_values(&:dup)
46
+
47
+ return defaults if value == UNSET_VALUE || value.nil?
48
+
49
+ overrides = normalize_binary_map(value)
50
+ defaults.merge(overrides) do |_key, _old, new_value|
51
+ Array(new_value)
52
+ end
53
+ end
54
+
55
+ def normalize_binary_map(map)
56
+ map.each_with_object({}) do |(key, raw_value), acc|
57
+ normalized_key = normalize_binary_key(key)
58
+ acc[normalized_key] = normalize_binary_value(raw_value)
59
+ end
60
+ end
61
+
62
+ def normalize_binary_key(key)
63
+ tuple = Array(key).map do |segment|
64
+ segment.respond_to?(:to_sym) ? segment.to_sym : segment
65
+ end
66
+
67
+ unless tuple.length == 2
68
+ raise ArgumentError, "Binary definitions must use two-part keys like [:linux, :x86_64]"
69
+ end
70
+
71
+ [tuple[0], tuple[1]]
72
+ end
73
+
74
+ def normalize_binary_value(value)
75
+ case value
76
+ when Array
77
+ value
78
+ when Hash
79
+ url = value[:url] || value['url']
80
+ checksum = value[:sha256] || value['sha256']
81
+ if url.nil? || checksum.nil?
82
+ raise ArgumentError, "Binary definition hash must include :url and :sha256 keys"
83
+ end
84
+ [url, checksum]
85
+ else
86
+ raise ArgumentError, "Binary definition must be an Array [url, sha256] or Hash with :url/:sha256"
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,71 @@
1
+ require 'vagrant'
2
+
3
+ $BOOT_SAVED = false
4
+
5
+ module VagrantPlugins
6
+ module VagrantNotifyForwarder
7
+ class Plugin < Vagrant.plugin('2')
8
+ name 'vagrant-notify-forwarder'
9
+ description 'Wrapper around the notify-forwarder file system event forwarder'
10
+
11
+ register_boot_hooks = lambda do |hook|
12
+ require_relative 'action/start_host_forwarder'
13
+ # require_relative 'action/stop_host_forwarder'
14
+ require_relative 'action/start_client_forwarder'
15
+ require_relative 'action/check_boot_state'
16
+
17
+ hook.before VagrantPlugins::ProviderVirtualBox::Action::Resume,
18
+ VagrantPlugins::VagrantNotifyForwarder::Action::CheckBootState
19
+ hook.after Vagrant::Action::Builtin::Provision,
20
+ VagrantPlugins::VagrantNotifyForwarder::Action::StartHostForwarder
21
+ hook.after VagrantPlugins::VagrantNotifyForwarder::Action::StartHostForwarder,
22
+ VagrantPlugins::VagrantNotifyForwarder::Action::StartClientForwarder
23
+ end
24
+
25
+ register_suspend_hooks = lambda do |hook|
26
+ require_relative 'action/stop_host_forwarder'
27
+
28
+ hook.before VagrantPlugins::ProviderVirtualBox::Action::Suspend,
29
+ VagrantPlugins::VagrantNotifyForwarder::Action::StopHostForwarder
30
+ end
31
+
32
+ register_resume_hooks = lambda do |hook|
33
+ require_relative 'action/start_host_forwarder'
34
+
35
+ hook.after VagrantPlugins::ProviderVirtualBox::Action::Provision,
36
+ VagrantPlugins::VagrantNotifyForwarder::Action::StartHostForwarder
37
+ end
38
+
39
+ register_halt_hooks = lambda do |hook|
40
+ require_relative 'action/stop_host_forwarder'
41
+
42
+ hook.before Vagrant::Action::Builtin::GracefulHalt,
43
+ VagrantPlugins::VagrantNotifyForwarder::Action::StopHostForwarder
44
+ end
45
+
46
+ register_destroy_hooks = lambda do |hook|
47
+ require_relative 'action/stop_host_forwarder'
48
+
49
+ hook.before Vagrant::Action::Builtin::GracefulHalt,
50
+ VagrantPlugins::VagrantNotifyForwarder::Action::StopHostForwarder
51
+ end
52
+
53
+ config(:notify_forwarder) do
54
+ require_relative 'config'
55
+ Config
56
+ end
57
+
58
+ action_hook :start_notify_forwarder, :machine_action_up, &register_boot_hooks
59
+ action_hook :start_notify_forwarder, :machine_action_reload, &register_boot_hooks
60
+
61
+ action_hook :stop_notify_forwarder, :machine_action_suspend, &register_suspend_hooks
62
+ action_hook :stop_notify_forwarder, :machine_action_resume, &register_resume_hooks
63
+
64
+ action_hook :stop_notify_forwarder, :machine_action_halt, &register_halt_hooks
65
+ action_hook :stop_notify_forwarder, :machine_action_reload, &register_halt_hooks
66
+
67
+ action_hook :stop_notify_forwarder, :machine_action_destroy, &register_destroy_hooks
68
+
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,97 @@
1
+ require 'uri'
2
+ require 'vagrant/util/downloader'
3
+
4
+ module VagrantPlugins
5
+ module VagrantNotifyForwarder
6
+ class Utils
7
+ @@OS_NAMES = {
8
+ "Linux" => :linux,
9
+ "Darwin" => :darwin,
10
+ "FreeBSD" => :freebsd,
11
+ }
12
+
13
+ @@HARDWARE_NAMES = {
14
+ "x86_64" => :x86_64,
15
+ "amd64" => :x86_64,
16
+ "arm64" => :arm64,
17
+ "aarch64" => :arm64,
18
+ }
19
+
20
+ def self.parse_os_name(data)
21
+ @@OS_NAMES[data.strip] or :unsupported
22
+ end
23
+
24
+ def self.parse_hardware_name(data)
25
+ @@HARDWARE_NAMES[data.strip] or :unsupported
26
+ end
27
+
28
+ def self.ensure_binary_downloaded(env, os, hardware)
29
+ config = env.fetch(:machine).config.notify_forwarder
30
+ download_map = config.binaries
31
+ url, sha256sum = download_map[[os, hardware]]
32
+
33
+ unless url && sha256sum
34
+ env[:ui].error "Notify-forwarder: No binary configured for host '#{os}' '#{hardware}'"
35
+ return
36
+ end
37
+
38
+ expanded_url = expand_binary_url(url)
39
+ env[:ui].info "Notify-forwarder: Using binary '#{expanded_url}' (sha256 #{sha256sum[0,8]}...) for '#{os}' '#{hardware}'"
40
+
41
+ uri = safe_parse_uri(expanded_url)
42
+ basename = File.basename(uri ? uri.path : expanded_url)
43
+ path = env[:tmp_path].join basename
44
+ should_download = true
45
+
46
+ if File.exist? path
47
+ digest = Digest::SHA256.file(path).hexdigest
48
+
49
+ if digest == sha256sum
50
+ should_download = false
51
+ end
52
+ end
53
+
54
+ if should_download
55
+ env[:ui].detail 'Notify-forwarder: Downloading client'
56
+ downloader = Vagrant::Util::Downloader.new expanded_url, path
57
+ downloader.download!
58
+ end
59
+
60
+ File.chmod(0755, path)
61
+
62
+ path
63
+ end
64
+
65
+ def self.expand_binary_url(url)
66
+ expanded = expand_environment(url.to_s)
67
+
68
+ if expanded.start_with?('file://')
69
+ uri = URI.parse(expanded)
70
+ uri.path = File.expand_path(uri.path)
71
+ return uri.to_s
72
+ end
73
+
74
+ return expanded if expanded =~ %r{^[a-zA-Z][a-zA-Z0-9+.-]*://}
75
+
76
+ File.expand_path(expanded)
77
+ end
78
+
79
+ def self.expand_environment(value)
80
+ value.gsub(/\$(\{)?([A-Za-z0-9_]+)\}?/) do
81
+ key = Regexp.last_match(2)
82
+ ENV.fetch(key, '')
83
+ end
84
+ end
85
+
86
+ def self.safe_parse_uri(url)
87
+ URI.parse(url)
88
+ rescue URI::InvalidURIError
89
+ nil
90
+ end
91
+
92
+ def self.host_pidfile(env)
93
+ env[:machine].data_dir.join('notify_watcher_host_pid')
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module VagrantNotifyForwarder
3
+ VERSION = "0.6.0"
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require 'vagrant-notify-forwarder/plugin'
2
+ require 'vagrant-notify-forwarder/config'
3
+
4
+ module VagrantPlugins
5
+ module VagrantNotifyForwarder
6
+ def self.source_root
7
+ @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-notify-forwarder/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-notify-forwarder2"
8
+ spec.version = VagrantPlugins::VagrantNotifyForwarder::VERSION
9
+ spec.authors = ["Chris Thomas"]
10
+ spec.email = ["chris.alex.thomas@gmail.com"]
11
+ spec.summary = "A vagrant plugin that forwards file system events from the host to the guest"
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/christhomas/vagrant-notify-forwarder"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.require_paths = ["lib"]
18
+ end
19
+
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-notify-forwarder2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Thomas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-09-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A vagrant plugin that forwards file system events from the host to the
14
+ guest
15
+ email:
16
+ - chris.alex.thomas@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/vagrant-notify-forwarder.rb
27
+ - lib/vagrant-notify-forwarder/action/check_boot_state.rb
28
+ - lib/vagrant-notify-forwarder/action/start_client_forwarder.rb
29
+ - lib/vagrant-notify-forwarder/action/start_host_forwarder.rb
30
+ - lib/vagrant-notify-forwarder/action/stop_host_forwarder.rb
31
+ - lib/vagrant-notify-forwarder/config.rb
32
+ - lib/vagrant-notify-forwarder/plugin.rb
33
+ - lib/vagrant-notify-forwarder/utils.rb
34
+ - lib/vagrant-notify-forwarder/version.rb
35
+ - vagrant-notify-forwarder.gemspec
36
+ homepage: https://github.com/christhomas/vagrant-notify-forwarder
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
+ rubygems_version: 3.0.3.1
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: A vagrant plugin that forwards file system events from the host to the guest
59
+ test_files: []