vagrant-hostsupdater 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/README.md +23 -17
- data/lib/vagrant-hostsupdater/Action/CacheHosts.rb +20 -0
- data/lib/vagrant-hostsupdater/Action/RemoveHosts.rb +7 -5
- data/lib/vagrant-hostsupdater/HostsUpdater.rb +10 -7
- data/lib/vagrant-hostsupdater/config.rb +1 -0
- data/lib/vagrant-hostsupdater/plugin.rb +6 -1
- data/lib/vagrant-hostsupdater/version.rb +1 -1
- metadata +45 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 51ccd0d56a1d0868f7dd00c567834fc5292e51b6
|
4
|
+
data.tar.gz: 0309736e690639b86ce559d0d6530d2e82c3ffdf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 41c2785d873b31de816a03dce41460927634c033e92c8250f1d62c84b25181db1f9d149d2e7920fdf0f0c3ac07fc792e0270fc8e667617439807fda3b9b65f77
|
7
|
+
data.tar.gz: 3c9b5067f24205f92e7e0a906fcd384e67004d08b3c626958bd41cc5d24c37377f531d1f4c592c45019f233eea44d05c819dc2d8b103e36b6010112a5a803d8b
|
data/README.md
CHANGED
@@ -9,8 +9,31 @@ By setting the remove\_on\_suspend option, you can have them removed on **suspen
|
|
9
9
|
|
10
10
|
config.hostsupdater.remove_on_suspend = true
|
11
11
|
|
12
|
+
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
$ vagrant plugin install vagrant-hostsupdater
|
17
|
+
|
18
|
+
Uninstall it with:
|
19
|
+
|
20
|
+
$ vagrant plugin uninstall vagrant-hostsupdater
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
At the moment, the only things you need, are the hostname and a :private_network network with a fixed ip.
|
25
|
+
|
26
|
+
config.vm.network :private_network, ip: "192.168.3.10"
|
27
|
+
config.vm.hostname = "www.testing.de"
|
28
|
+
config.hostsupdater.aliases = ["alias.testing.de", "alias2.somedomain.com"]
|
29
|
+
|
30
|
+
This ip and the hostname will be used for the entry in the /etc/hosts file.
|
31
|
+
|
12
32
|
## Versions
|
13
33
|
|
34
|
+
### 0.0.11
|
35
|
+
* bugfix: Fix additional new lines being added to hosts file (Thanks to vincentmac)
|
36
|
+
|
14
37
|
### 0.0.10
|
15
38
|
* bugfix: wrong path on Windows systems (Thanks to Im0rtality)
|
16
39
|
|
@@ -36,23 +59,6 @@ By setting the remove\_on\_suspend option, you can have them removed on **suspen
|
|
36
59
|
### 0.0.3
|
37
60
|
* added aliases config option to define additional hostnames
|
38
61
|
|
39
|
-
## Installation
|
40
|
-
|
41
|
-
$ vagrant plugin install vagrant-hostsupdater
|
42
|
-
|
43
|
-
Uninstall it with:
|
44
|
-
|
45
|
-
$ vagrant plugin uninstall vagrant-hostsupdater
|
46
|
-
|
47
|
-
## Usage
|
48
|
-
|
49
|
-
At the moment, the only things you need, are the hostname and a :private_network network with a fixed ip.
|
50
|
-
|
51
|
-
config.vm.network :private_network, ip: "192.168.3.10"
|
52
|
-
config.vm.hostname = "www.testing.de"
|
53
|
-
config.hostsupdater.aliases = ["alias.testing.de", "alias2.somedomain.com"]
|
54
|
-
|
55
|
-
This ip and the hostname will be used for the entry in the /etc/hosts file.
|
56
62
|
|
57
63
|
## Contributing
|
58
64
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module HostsUpdater
|
3
|
+
module Action
|
4
|
+
class CacheHosts
|
5
|
+
include HostsUpdater
|
6
|
+
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
@machine = env[:machine]
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
cacheHostEntries
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -12,11 +12,13 @@ module VagrantPlugins
|
|
12
12
|
|
13
13
|
def call(env)
|
14
14
|
machine_action = env[:machine_action]
|
15
|
-
if machine_action != :
|
16
|
-
@
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
if machine_action != :destroy || !@machine.id
|
16
|
+
if machine_action != :suspend || @machine.config.hostsupdater.remove_on_suspend
|
17
|
+
@ui.info "Removing hosts"
|
18
|
+
removeHostEntries
|
19
|
+
else
|
20
|
+
@ui.info "Removing hosts on suspend disabled"
|
21
|
+
end
|
20
22
|
end
|
21
23
|
@app.call(env)
|
22
24
|
end
|
@@ -42,14 +42,18 @@ module VagrantPlugins
|
|
42
42
|
addToHosts(entries)
|
43
43
|
end
|
44
44
|
|
45
|
+
def cacheHostEntries
|
46
|
+
@machine.config.hostsupdater.id = @machine.id
|
47
|
+
end
|
48
|
+
|
45
49
|
def removeHostEntries
|
46
|
-
if !@machine.id
|
50
|
+
if !@machine.id and !@machine.config.hostsupdater.id
|
47
51
|
@ui.warn "No machine id, nothing removed from #@@hosts_path"
|
48
52
|
return
|
49
53
|
end
|
50
54
|
file = File.open(@@hosts_path, "rb")
|
51
55
|
hostsContents = file.read
|
52
|
-
uuid = @machine.id
|
56
|
+
uuid = @machine.id || @machine.config.hostsupdater.id
|
53
57
|
hashedId = Digest::MD5.hexdigest(uuid)
|
54
58
|
if hostsContents.match(/#{hashedId}/)
|
55
59
|
removeFromHosts
|
@@ -70,20 +74,19 @@ module VagrantPlugins
|
|
70
74
|
|
71
75
|
def addToHosts(entries)
|
72
76
|
return if entries.length == 0
|
73
|
-
content =
|
77
|
+
content = entries.join("\n").strip
|
74
78
|
if !File.writable?(@@hosts_path)
|
75
79
|
sudo(%Q(sh -c 'echo "#{content}" >> #@@hosts_path'))
|
76
80
|
else
|
81
|
+
content = "\n" + content
|
77
82
|
hostsFile = File.open(@@hosts_path, "a")
|
78
83
|
hostsFile.write(content)
|
79
84
|
hostsFile.close()
|
80
85
|
end
|
81
|
-
|
82
|
-
|
83
86
|
end
|
84
87
|
|
85
88
|
def removeFromHosts(options = {})
|
86
|
-
uuid = @machine.id
|
89
|
+
uuid = @machine.id || @machine.config.hostsupdater.id
|
87
90
|
hashedId = Digest::MD5.hexdigest(uuid)
|
88
91
|
if !File.writable?(@@hosts_path)
|
89
92
|
sudo(%Q(sed -i -e '/#{hashedId}/ d' #@@hosts_path))
|
@@ -115,4 +118,4 @@ module VagrantPlugins
|
|
115
118
|
end
|
116
119
|
end
|
117
120
|
end
|
118
|
-
end
|
121
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "vagrant-hostsupdater/Action/UpdateHosts"
|
2
|
+
require "vagrant-hostsupdater/Action/CacheHosts"
|
2
3
|
require "vagrant-hostsupdater/Action/RemoveHosts"
|
3
4
|
|
4
5
|
module VagrantPlugins
|
@@ -28,7 +29,11 @@ module VagrantPlugins
|
|
28
29
|
end
|
29
30
|
|
30
31
|
action_hook(:hostsupdater, :machine_action_destroy) do |hook|
|
31
|
-
hook.prepend(Action::
|
32
|
+
hook.prepend(Action::CacheHosts)
|
33
|
+
end
|
34
|
+
|
35
|
+
action_hook(:hostsupdater, :machine_action_destroy) do |hook|
|
36
|
+
hook.append(Action::RemoveHosts)
|
32
37
|
end
|
33
38
|
|
34
39
|
action_hook(:hostsupdater, :machine_action_reload) do |hook|
|
metadata
CHANGED
@@ -1,53 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-hostsupdater
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
-
|
6
|
+
authors:
|
7
|
+
- Falk Kühnel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
prerelease: false
|
16
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - ~>
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: "1.3"
|
11
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
22
20
|
type: :development
|
23
|
-
requirement: *id001
|
24
|
-
- !ruby/object:Gem::Dependency
|
25
21
|
prerelease: false
|
26
|
-
version_requirements:
|
27
|
-
requirements:
|
28
|
-
-
|
29
|
-
-
|
30
|
-
|
31
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
32
28
|
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
33
34
|
type: :development
|
34
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
35
41
|
description: Enables Vagrant to update hosts file on the host machine
|
36
|
-
email:
|
42
|
+
email:
|
37
43
|
- fk@cogitatio.de
|
38
44
|
executables: []
|
39
|
-
|
40
45
|
extensions: []
|
41
|
-
|
42
46
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
47
|
+
files:
|
45
48
|
- .gitignore
|
46
49
|
- Gemfile
|
47
50
|
- LICENSE.txt
|
48
51
|
- README.md
|
49
52
|
- Rakefile
|
50
53
|
- lib/vagrant-hostsupdater.rb
|
54
|
+
- lib/vagrant-hostsupdater/Action/CacheHosts.rb
|
51
55
|
- lib/vagrant-hostsupdater/Action/RemoveHosts.rb
|
52
56
|
- lib/vagrant-hostsupdater/Action/UpdateHosts.rb
|
53
57
|
- lib/vagrant-hostsupdater/HostsUpdater.rb
|
@@ -57,27 +61,27 @@ files:
|
|
57
61
|
- lib/vagrant-hostsupdater/version.rb
|
58
62
|
- vagrant-hostsupdater.gemspec
|
59
63
|
homepage: https://github.com/cogitatio/vagrant-hostsupdater
|
60
|
-
licenses:
|
64
|
+
licenses:
|
61
65
|
- MIT
|
62
66
|
metadata: {}
|
63
|
-
|
64
67
|
post_install_message:
|
65
68
|
rdoc_options: []
|
66
|
-
|
67
|
-
require_paths:
|
69
|
+
require_paths:
|
68
70
|
- lib
|
69
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
75
81
|
requirements: []
|
76
|
-
|
77
82
|
rubyforge_project:
|
78
83
|
rubygems_version: 2.0.3
|
79
84
|
signing_key:
|
80
85
|
specification_version: 4
|
81
86
|
summary: Enables Vagrant to update hosts file on the host machine
|
82
87
|
test_files: []
|
83
|
-
|