vagrant-dnsdock-hostupdater 0.0.10

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.
@@ -0,0 +1,91 @@
1
+ module Vagrant
2
+ module DnsdockHostUpdater
3
+
4
+ module OS
5
+ def OS.windows?
6
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
7
+ end
8
+
9
+ def OS.mac?
10
+ (/darwin/ =~ RUBY_PLATFORM) != nil
11
+ end
12
+
13
+ def OS.unix?
14
+ !OS.windows?
15
+ end
16
+
17
+ def OS.linux?
18
+ OS.unix? and not OS.mac?
19
+ end
20
+ end
21
+
22
+ class Plugin < Vagrant.plugin('2')
23
+ name "dnsdock-host-updater"
24
+
25
+ description <<-DESC
26
+ Updates hosts for docker containers on guest VM.
27
+ DESC
28
+
29
+ @started = false
30
+
31
+ # Add command for `$ vagrant dnsdock-host-updater`
32
+ # command 'dnsdock-host-updater' do
33
+ # require_relative 'command'
34
+ # Command
35
+ # end
36
+
37
+ def self.pid_path
38
+ File.expand_path('~/.docker-host-manager.pid')
39
+ end
40
+
41
+ def self.log(msg)
42
+ puts "[vagrant-dnsdock-hostupdater] #{msg}"
43
+ end
44
+
45
+ def self.pid
46
+ File.exist?(pid_path) ? File.read(pid_path) : nil
47
+ end
48
+
49
+ def self.close_manager
50
+ if pid
51
+ log "Already running with PID: #{pid}"
52
+ begin
53
+ log "Attempting to stop server with PID: #{pid}"
54
+ Process.kill('KILL', pid.to_i)
55
+ rescue
56
+ log "Unable to kill process with ID: #{pid}. This may be because the process has already been terminated."
57
+ end
58
+
59
+ log "Cleaning up PID file: #{pid_path}"
60
+ File.delete(pid_path)
61
+ end
62
+ end
63
+
64
+ def self.init_plugin(config)
65
+ server_path = File.expand_path('../../server.rb', __FILE__)
66
+
67
+ if @started
68
+ return
69
+ end
70
+
71
+ close_manager
72
+
73
+ Thread.new do
74
+ pid = spawn "ruby #{server_path}"
75
+ log "Started server with PID: #{pid}"
76
+
77
+ if pid
78
+ pid_file = File.open(pid_path, 'w')
79
+ pid_file << pid
80
+ pid_file.close
81
+ log "Wrote server PID (#{pid}) to #{pid_path}"
82
+ @started = true
83
+ end
84
+ end
85
+ end
86
+
87
+ action_hook(:up, :machine_action_up) { init_plugin(@config) }
88
+
89
+ end
90
+ end
91
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module DnsdockHostUpdater
3
+ VERSION = '0.0.10'.freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-dnsdock-hostupdater
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.10
5
+ platform: ruby
6
+ authors:
7
+ - Brian Coit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: docker-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.33'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.33'
27
+ - !ruby/object:Gem::Dependency
28
+ name: log4r
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.10
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.10
41
+ - !ruby/object:Gem::Dependency
42
+ name: linebreak
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.1.0
55
+ description: A Vagrant plugin for managing hosts file on host machine.
56
+ email: brian.coit@cellosignal.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - Rakefile
62
+ - lib/client.rb
63
+ - lib/event-watcher.rb
64
+ - lib/host-manager.rb
65
+ - lib/hosts/aef/hosts.rb
66
+ - lib/hosts/aef/hosts/comment.rb
67
+ - lib/hosts/aef/hosts/element.rb
68
+ - lib/hosts/aef/hosts/empty_element.rb
69
+ - lib/hosts/aef/hosts/entry.rb
70
+ - lib/hosts/aef/hosts/file.rb
71
+ - lib/hosts/aef/hosts/helpers.rb
72
+ - lib/hosts/aef/hosts/section.rb
73
+ - lib/hosts/aef/hosts/version.rb
74
+ - lib/hosts/aef/linebreak/linebreak.rb
75
+ - lib/hosts/hosts.rb
76
+ - lib/hosts/hosts/bare.rb
77
+ - lib/launch-control
78
+ - lib/server.rb
79
+ - lib/vagrant-dnsdock-hostupdater.rb
80
+ - lib/vagrant-dnsdock-hostupdater/command.rb
81
+ - lib/vagrant-dnsdock-hostupdater/plugin.rb
82
+ - lib/version.rb
83
+ homepage: https://bitbucket.org/blonde/shore
84
+ licenses:
85
+ - GNU
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.5.2
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Update hosts
107
+ test_files: []