vagrant-rubydns 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ext/rexec.rb ADDED
@@ -0,0 +1,10 @@
1
+ # Monkey patch in a prefix for the RExec daemon log lines.
2
+ module RExec
3
+ module Daemon
4
+ module Controller
5
+ def self.puts(str)
6
+ Kernel.puts "[vagrant-rubydns] #{str}"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -14,9 +14,14 @@ module VagrantRubydns
14
14
  end
15
15
  end
16
16
 
17
- require 'vagrant-rubydns/plugin'
18
- require 'vagrant-rubydns/store'
17
+ require 'rubydns'
18
+
19
19
  require 'vagrant-rubydns/dependent_vms'
20
+ require 'vagrant-rubydns/plugin'
21
+ require 'vagrant-rubydns/resolver_config'
20
22
  require 'vagrant-rubydns/server'
23
+ require 'vagrant-rubydns/store'
21
24
  require 'vagrant-rubydns/util'
22
25
  require 'vagrant-rubydns/version'
26
+
27
+ require 'ext/rexec'
@@ -0,0 +1,53 @@
1
+ require 'tempfile'
2
+
3
+ module VagrantRubydns
4
+ class ResolverConfig
5
+ def self.desired_contents; <<-EOS.gsub(/^ /, '')
6
+ # Generated by vagrant-rubydns
7
+ nameserver 127.0.0.1
8
+ port 10053
9
+ EOS
10
+ end
11
+
12
+ def self.osx?
13
+ `uname`.chomp == 'Darwin'
14
+ end
15
+
16
+ def self.config_file
17
+ Pathname('/etc/resolver/vagrant.dev')
18
+ end
19
+
20
+ def self.contents_match?
21
+ config_file.exist? && File.read(config_file) == desired_contents
22
+ end
23
+
24
+ def self.write_config
25
+ puts "Mometarily using sudo to put the host config in place..."
26
+ Tempfile.open('vagrant_rubydns_host_config') do |f|
27
+ f.write(desired_contents)
28
+ f.close
29
+ `sudo cp #{f.path} /etc/resolver/vagrant.dev`
30
+ `sudo chown root:wheel /etc/resolver/vagrant.dev`
31
+ `sudo chmod 644 /etc/resolver/vagrant.dev`
32
+ end
33
+ end
34
+
35
+ def self.ensure_config_exists
36
+ unless osx?
37
+ puts "Not an OSX machine, so skipping host DNS resolver config."
38
+ return
39
+ end
40
+
41
+ if contents_match?
42
+ puts "Host DNS resolver config looks good."
43
+ else
44
+ puts "Need to configure the host."
45
+ write_config
46
+ end
47
+ end
48
+
49
+ def self.puts(str)
50
+ Kernel.puts("[vagrant-rubydns] #{str}")
51
+ end
52
+ end
53
+ end
@@ -25,6 +25,10 @@ module VagrantRubydns
25
25
  RExec::Daemon::ProcessFile.status(self) == :running
26
26
  end
27
27
 
28
+ def self.prefork
29
+ ResolverConfig.ensure_config_exists
30
+ end
31
+
28
32
  def self.run
29
33
  server = self
30
34
  RubyDNS::run_server(:listen => INTERFACES) do
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Rubydns
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-rubydns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -72,6 +72,7 @@ files:
72
72
  - README.md
73
73
  - Rakefile
74
74
  - examples/Vagrantfile
75
+ - lib/ext/rexec.rb
75
76
  - lib/vagrant-rubydns.rb
76
77
  - lib/vagrant-rubydns/action/redirect_dns.rb
77
78
  - lib/vagrant-rubydns/action/setup.rb
@@ -80,6 +81,7 @@ files:
80
81
  - lib/vagrant-rubydns/config.rb
81
82
  - lib/vagrant-rubydns/dependent_vms.rb
82
83
  - lib/vagrant-rubydns/plugin.rb
84
+ - lib/vagrant-rubydns/resolver_config.rb
83
85
  - lib/vagrant-rubydns/server.rb
84
86
  - lib/vagrant-rubydns/store.rb
85
87
  - lib/vagrant-rubydns/util.rb