vagrant-notify-forwarder-christhomas 0.7.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 +7 -0
- data/.github/workflows/release.yml +39 -0
- data/.gitignore +28 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +138 -0
- data/Rakefile +46 -0
- data/lib/vagrant-notify-forwarder/action/check_boot_state.rb +18 -0
- data/lib/vagrant-notify-forwarder/action/start_client_forwarder.rb +59 -0
- data/lib/vagrant-notify-forwarder/action/start_host_forwarder.rb +61 -0
- data/lib/vagrant-notify-forwarder/action/stop_host_forwarder.rb +34 -0
- data/lib/vagrant-notify-forwarder/config.rb +111 -0
- data/lib/vagrant-notify-forwarder/plugin.rb +71 -0
- data/lib/vagrant-notify-forwarder/utils.rb +98 -0
- data/lib/vagrant-notify-forwarder/version.rb +5 -0
- data/lib/vagrant-notify-forwarder-christhomas.rb +1 -0
- data/lib/vagrant-notify-forwarder.rb +10 -0
- data/vagrant-notify-forwarder-christhomas.gemspec +19 -0
- metadata +62 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ebd442143f0bfe525439a82b8925276cf3445c5ecade651897eb8e0f8dc75f9a
|
|
4
|
+
data.tar.gz: 854a72e1dbb009415d0eb9d59d4c099e2883bcb7b6d0ef288c2e269cb3728cd4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e90f2898da93aa0466704842678f5c268c6efd614f01721354beaba4a4b761d20b1f20ddc38b66e2e9b3d539cf127d6fc698fb326873153a58f101aa9353e957
|
|
7
|
+
data.tar.gz: 04cf72017184d7f7858408b49ab6a49cc034d3eee25a2f60e0f3542df90c76c98d72a14866c2778352d8ca6003d82c9d6d12a8e6d85dca5c126d5bf7dd9b9d03
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Release gem
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Ruby
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
|
+
with:
|
|
21
|
+
ruby-version: '3.3'
|
|
22
|
+
|
|
23
|
+
- name: Build gem
|
|
24
|
+
run: gem build vagrant-notify-forwarder-christhomas.gemspec
|
|
25
|
+
|
|
26
|
+
- name: Publish to RubyGems
|
|
27
|
+
uses: rubygems/release-gem@v1
|
|
28
|
+
|
|
29
|
+
- name: Create GitHub Release
|
|
30
|
+
uses: softprops/action-gh-release@v2
|
|
31
|
+
with:
|
|
32
|
+
files: vagrant-notify-forwarder-christhomas-*.gem
|
|
33
|
+
body: |
|
|
34
|
+
vagrant-notify-forwarder-christhomas ${{ github.ref_name }}
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
```
|
|
38
|
+
vagrant plugin install vagrant-notify-forwarder-christhomas
|
|
39
|
+
```
|
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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v0.7.0
|
|
4
|
+
|
|
5
|
+
- Added Linux armv7l (ARM32) guest support
|
|
6
|
+
- Updated all notify-forwarder binaries to v1.1.0
|
|
7
|
+
- Updated all SHA256 checksums
|
|
8
|
+
- Added armv7l to hardware name detection
|
|
9
|
+
|
|
10
|
+
## v0.6.3
|
|
11
|
+
|
|
12
|
+
- Added auto-correct for UDP port conflicts — tries next 10 ports if default is in use
|
|
13
|
+
- Added `auto_correct: true` to forwarded port declaration
|
|
14
|
+
- Added GitHub Actions release pipeline (triggers on version tags)
|
|
15
|
+
- Added Homebrew formula for installation via `brew install antimatter-studios/tap/vagrant-notify-forwarder`
|
|
16
|
+
|
|
17
|
+
## v0.6.2
|
|
18
|
+
|
|
19
|
+
- Added configurable binary sources via `config.notify_forwarder.binaries`
|
|
20
|
+
- Added support for macOS ARM64 (Apple Silicon) and Linux ARM64
|
|
21
|
+
- Updated notify-forwarder binaries to v1.0.0
|
data/Gemfile
ADDED
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,138 @@
|
|
|
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
|
|
11
|
+
|
|
12
|
+
### Via Homebrew (recommended)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
brew install antimatter-studios/tap/vagrant-notify-forwarder
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This downloads the gem and runs `vagrant plugin install` automatically.
|
|
19
|
+
|
|
20
|
+
### Manual install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
vagrant plugin install vagrant-notify-forwarder2
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or from a specific release:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
curl -fsSL -o /tmp/vagrant-notify-forwarder2.gem \
|
|
30
|
+
https://github.com/christhomas/vagrant-notify-forwarder/releases/download/v0.6.3/vagrant-notify-forwarder2-0.6.3.gem
|
|
31
|
+
vagrant plugin install /tmp/vagrant-notify-forwarder2.gem
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
After installing, reload your Vagrant environment:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
vagrant reload
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Configuration
|
|
41
|
+
|
|
42
|
+
### Port
|
|
43
|
+
|
|
44
|
+
By default, the plugin uses UDP port 29324. If multiple VMs are running, the
|
|
45
|
+
port is automatically corrected to the next available port (tries up to 10 ports).
|
|
46
|
+
|
|
47
|
+
To set a specific port:
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
config.notify_forwarder.port = 22020
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Disabling
|
|
54
|
+
|
|
55
|
+
To disable the plugin for a specific machine:
|
|
56
|
+
|
|
57
|
+
```ruby
|
|
58
|
+
config.notify_forwarder.enable = false
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Permissions
|
|
62
|
+
|
|
63
|
+
The client in the guest OS runs as root by default, assuming passwordless `sudo` works. To disable
|
|
64
|
+
privilege escalation:
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
config.notify_forwarder.run_as_root = false
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Overriding binary sources
|
|
71
|
+
|
|
72
|
+
The plugin ships with a default map of download URLs and SHA256 checksums for each supported
|
|
73
|
+
`[os, hardware]` combination. You can override or extend the map via
|
|
74
|
+
`config.notify_forwarder.binaries`:
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
config.notify_forwarder.binaries = {
|
|
78
|
+
[:darwin, :arm64] => {
|
|
79
|
+
url: "https://example.com/notify-forwarder-osx-arm64",
|
|
80
|
+
sha256: "deadbeef..."
|
|
81
|
+
},
|
|
82
|
+
[:linux, :riscv64] => [
|
|
83
|
+
"https://example.com/notify-forwarder-linux-riscv64",
|
|
84
|
+
"cafebabe..."
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
You may supply each entry either as an array `[url, sha256]` or a hash with `:url`/`:sha256` keys.
|
|
90
|
+
Entries you omit continue using the built-in defaults.
|
|
91
|
+
|
|
92
|
+
## Supported platforms
|
|
93
|
+
|
|
94
|
+
The plugin downloads binaries for supported platforms:
|
|
95
|
+
|
|
96
|
+
| Platform | Host | Guest |
|
|
97
|
+
|----------|------|-------|
|
|
98
|
+
| Linux arm64 | ✓ | ✓ |
|
|
99
|
+
| Linux armv7l | — | ✓ |
|
|
100
|
+
| Linux x86_64 | ✓ | ✓ |
|
|
101
|
+
| macOS arm64 | ✓ | — |
|
|
102
|
+
| macOS x86_64 | ✓ | — |
|
|
103
|
+
|
|
104
|
+
## Development
|
|
105
|
+
|
|
106
|
+
Use Bundler and the project `Rakefile` to keep all tooling local to the repository.
|
|
107
|
+
|
|
108
|
+
1. Install dependencies:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
rake dev:bundle
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
2. Build the gem:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
bundle exec rake dev:build
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
3. Install locally for testing:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
bundle exec rake dev:install
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
4. Launch or reload Vagrant:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
bundle exec rake dev:up
|
|
130
|
+
bundle exec rake dev:reload
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Contributors
|
|
134
|
+
|
|
135
|
+
* [CharlieC3](https://github.com/CharlieC3)
|
|
136
|
+
* [hedinfaok](https://github.com/hedinfaok)
|
|
137
|
+
* [seff](https://github.com/seff)
|
|
138
|
+
* [christhomas](https://github.com/christhomas)
|
data/Rakefile
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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 'Push the gem to RubyGems (requires configured credentials)'
|
|
33
|
+
task :publish => :build do
|
|
34
|
+
sh "gem push #{GEM_PACKAGE}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
desc 'Run vagrant up using the bundled environment and local plugin path'
|
|
38
|
+
task :up => :bundle do
|
|
39
|
+
sh 'bundle exec vagrant up'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc 'Reload the running Vagrant environment via Bundler'
|
|
43
|
+
task :reload => :bundle do
|
|
44
|
+
sh 'bundle exec vagrant reload'
|
|
45
|
+
end
|
|
46
|
+
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', auto_correct: true
|
|
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,111 @@
|
|
|
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.1.0/notify-forwarder-linux_x86_64',
|
|
12
|
+
'baee3d06acccd126b37c8e9abd73cfd3ab3a83886eeb7572d36d9e0e38177a24'
|
|
13
|
+
],
|
|
14
|
+
[:linux, :arm64] => [
|
|
15
|
+
'https://github.com/christhomas/notify-forwarder/releases/download/v1.1.0/notify-forwarder-linux_arm64',
|
|
16
|
+
'a9bace65cbefc99db78e2e6fb47e55ed9df2ddf460c173dee7400d70de25c9c0'
|
|
17
|
+
],
|
|
18
|
+
[:linux, :armv7l] => [
|
|
19
|
+
'https://github.com/christhomas/notify-forwarder/releases/download/v1.1.0/notify-forwarder-linux_armv7l',
|
|
20
|
+
'35e05a9af6cb50417919b0cc579b0ecdc87160be811bdac651488e3bbeb19bbe'
|
|
21
|
+
],
|
|
22
|
+
[:darwin, :x86_64] => [
|
|
23
|
+
'https://github.com/christhomas/notify-forwarder/releases/download/v1.1.0/notify-forwarder-darwin_x86_64',
|
|
24
|
+
'195fde3f90425c8e73b59d832f9cf5ecf98857fa3b992ba1bd6cfbdd749ca96a'
|
|
25
|
+
],
|
|
26
|
+
[:darwin, :arm64] => [
|
|
27
|
+
'https://github.com/christhomas/notify-forwarder/releases/download/v1.1.0/notify-forwarder-darwin_arm64',
|
|
28
|
+
'ac78532672553174bfc20e3c3d5d5c9fdccfe51d5fee5521bf34a3168d4acb34'
|
|
29
|
+
],
|
|
30
|
+
}.freeze
|
|
31
|
+
|
|
32
|
+
def initialize
|
|
33
|
+
@port = UNSET_VALUE
|
|
34
|
+
@enable = UNSET_VALUE
|
|
35
|
+
@run_as_root = UNSET_VALUE
|
|
36
|
+
@binaries = UNSET_VALUE
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def finalize!
|
|
40
|
+
@port = 29324 if @port == UNSET_VALUE
|
|
41
|
+
@port = auto_correct_port(@port)
|
|
42
|
+
@enable = true if @enable == UNSET_VALUE
|
|
43
|
+
@run_as_root = true if @run_as_root == UNSET_VALUE
|
|
44
|
+
@binaries = prepare_binaries(@binaries)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def auto_correct_port(port)
|
|
50
|
+
require 'socket'
|
|
51
|
+
10.times do
|
|
52
|
+
begin
|
|
53
|
+
socket = UDPSocket.new
|
|
54
|
+
socket.bind('127.0.0.1', port)
|
|
55
|
+
socket.close
|
|
56
|
+
return port
|
|
57
|
+
rescue Errno::EADDRINUSE
|
|
58
|
+
port += 1
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
port
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def prepare_binaries(value)
|
|
65
|
+
defaults = DEFAULT_BINARIES.transform_values(&:dup)
|
|
66
|
+
|
|
67
|
+
return defaults if value == UNSET_VALUE || value.nil?
|
|
68
|
+
|
|
69
|
+
overrides = normalize_binary_map(value)
|
|
70
|
+
defaults.merge(overrides) do |_key, _old, new_value|
|
|
71
|
+
Array(new_value)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def normalize_binary_map(map)
|
|
76
|
+
map.each_with_object({}) do |(key, raw_value), acc|
|
|
77
|
+
normalized_key = normalize_binary_key(key)
|
|
78
|
+
acc[normalized_key] = normalize_binary_value(raw_value)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def normalize_binary_key(key)
|
|
83
|
+
tuple = Array(key).map do |segment|
|
|
84
|
+
segment.respond_to?(:to_sym) ? segment.to_sym : segment
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
unless tuple.length == 2
|
|
88
|
+
raise ArgumentError, "Binary definitions must use two-part keys like [:linux, :x86_64]"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
[tuple[0], tuple[1]]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def normalize_binary_value(value)
|
|
95
|
+
case value
|
|
96
|
+
when Array
|
|
97
|
+
value
|
|
98
|
+
when Hash
|
|
99
|
+
url = value[:url] || value['url']
|
|
100
|
+
checksum = value[:sha256] || value['sha256']
|
|
101
|
+
if url.nil? || checksum.nil?
|
|
102
|
+
raise ArgumentError, "Binary definition hash must include :url and :sha256 keys"
|
|
103
|
+
end
|
|
104
|
+
[url, checksum]
|
|
105
|
+
else
|
|
106
|
+
raise ArgumentError, "Binary definition must be an Array [url, sha256] or Hash with :url/:sha256"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
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, ®ister_boot_hooks
|
|
59
|
+
action_hook :start_notify_forwarder, :machine_action_reload, ®ister_boot_hooks
|
|
60
|
+
|
|
61
|
+
action_hook :stop_notify_forwarder, :machine_action_suspend, ®ister_suspend_hooks
|
|
62
|
+
action_hook :stop_notify_forwarder, :machine_action_resume, ®ister_resume_hooks
|
|
63
|
+
|
|
64
|
+
action_hook :stop_notify_forwarder, :machine_action_halt, ®ister_halt_hooks
|
|
65
|
+
action_hook :stop_notify_forwarder, :machine_action_reload, ®ister_halt_hooks
|
|
66
|
+
|
|
67
|
+
action_hook :stop_notify_forwarder, :machine_action_destroy, ®ister_destroy_hooks
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
"armv7l" => :armv7l,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
def self.parse_os_name(data)
|
|
22
|
+
@@OS_NAMES[data.strip] or :unsupported
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.parse_hardware_name(data)
|
|
26
|
+
@@HARDWARE_NAMES[data.strip] or :unsupported
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.ensure_binary_downloaded(env, os, hardware)
|
|
30
|
+
config = env.fetch(:machine).config.notify_forwarder
|
|
31
|
+
download_map = config.binaries
|
|
32
|
+
url, sha256sum = download_map[[os, hardware]]
|
|
33
|
+
|
|
34
|
+
unless url && sha256sum
|
|
35
|
+
env[:ui].error "Notify-forwarder: No binary configured for host '#{os}' '#{hardware}'"
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
expanded_url = expand_binary_url(url)
|
|
40
|
+
env[:ui].info "Notify-forwarder: Using binary '#{expanded_url}' (sha256 #{sha256sum[0,8]}...) for '#{os}' '#{hardware}'"
|
|
41
|
+
|
|
42
|
+
uri = safe_parse_uri(expanded_url)
|
|
43
|
+
basename = File.basename(uri ? uri.path : expanded_url)
|
|
44
|
+
path = env[:tmp_path].join basename
|
|
45
|
+
should_download = true
|
|
46
|
+
|
|
47
|
+
if File.exist? path
|
|
48
|
+
digest = Digest::SHA256.file(path).hexdigest
|
|
49
|
+
|
|
50
|
+
if digest == sha256sum
|
|
51
|
+
should_download = false
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if should_download
|
|
56
|
+
env[:ui].detail 'Notify-forwarder: Downloading client'
|
|
57
|
+
downloader = Vagrant::Util::Downloader.new expanded_url, path
|
|
58
|
+
downloader.download!
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
File.chmod(0755, path)
|
|
62
|
+
|
|
63
|
+
path
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.expand_binary_url(url)
|
|
67
|
+
expanded = expand_environment(url.to_s)
|
|
68
|
+
|
|
69
|
+
if expanded.start_with?('file://')
|
|
70
|
+
uri = URI.parse(expanded)
|
|
71
|
+
uri.path = File.expand_path(uri.path)
|
|
72
|
+
return uri.to_s
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
return expanded if expanded =~ %r{^[a-zA-Z][a-zA-Z0-9+.-]*://}
|
|
76
|
+
|
|
77
|
+
File.expand_path(expanded)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def self.expand_environment(value)
|
|
81
|
+
value.gsub(/\$(\{)?([A-Za-z0-9_]+)\}?/) do
|
|
82
|
+
key = Regexp.last_match(2)
|
|
83
|
+
ENV.fetch(key, '')
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.safe_parse_uri(url)
|
|
88
|
+
URI.parse(url)
|
|
89
|
+
rescue URI::InvalidURIError
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.host_pidfile(env)
|
|
94
|
+
env[:machine].data_dir.join('notify_watcher_host_pid')
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'vagrant-notify-forwarder'
|
|
@@ -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-forwarder-christhomas"
|
|
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,62 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: vagrant-notify-forwarder-christhomas
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.7.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Chris Thomas
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-04-03 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
|
+
- ".github/workflows/release.yml"
|
|
22
|
+
- ".gitignore"
|
|
23
|
+
- CHANGELOG.md
|
|
24
|
+
- Gemfile
|
|
25
|
+
- LICENSE.txt
|
|
26
|
+
- README.md
|
|
27
|
+
- Rakefile
|
|
28
|
+
- lib/vagrant-notify-forwarder-christhomas.rb
|
|
29
|
+
- lib/vagrant-notify-forwarder.rb
|
|
30
|
+
- lib/vagrant-notify-forwarder/action/check_boot_state.rb
|
|
31
|
+
- lib/vagrant-notify-forwarder/action/start_client_forwarder.rb
|
|
32
|
+
- lib/vagrant-notify-forwarder/action/start_host_forwarder.rb
|
|
33
|
+
- lib/vagrant-notify-forwarder/action/stop_host_forwarder.rb
|
|
34
|
+
- lib/vagrant-notify-forwarder/config.rb
|
|
35
|
+
- lib/vagrant-notify-forwarder/plugin.rb
|
|
36
|
+
- lib/vagrant-notify-forwarder/utils.rb
|
|
37
|
+
- lib/vagrant-notify-forwarder/version.rb
|
|
38
|
+
- vagrant-notify-forwarder-christhomas.gemspec
|
|
39
|
+
homepage: https://github.com/christhomas/vagrant-notify-forwarder
|
|
40
|
+
licenses:
|
|
41
|
+
- MIT
|
|
42
|
+
metadata: {}
|
|
43
|
+
post_install_message:
|
|
44
|
+
rdoc_options: []
|
|
45
|
+
require_paths:
|
|
46
|
+
- lib
|
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
|
+
requirements:
|
|
49
|
+
- - ">="
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '0'
|
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
requirements: []
|
|
58
|
+
rubygems_version: 3.0.3.1
|
|
59
|
+
signing_key:
|
|
60
|
+
specification_version: 4
|
|
61
|
+
summary: A vagrant plugin that forwards file system events from the host to the guest
|
|
62
|
+
test_files: []
|