vagrant-vbguest 0.6.0.pre1 → 0.6.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vagrant-vbguest.rb +2 -0
- data/lib/vagrant-vbguest/command.rb +45 -10
- data/lib/vagrant-vbguest/helpers.rb +4 -2
- data/lib/vagrant-vbguest/installer.rb +24 -58
- data/lib/vagrant-vbguest/installers/base.rb +70 -21
- data/lib/vagrant-vbguest/installers/debian.rb +7 -2
- data/lib/vagrant-vbguest/installers/linux.rb +21 -1
- data/lib/vagrant-vbguest/machine.rb +83 -0
- data/lib/vagrant-vbguest/middleware.rb +6 -10
- data/lib/vagrant-vbguest/version.rb +1 -1
- data/locales/en.yml +12 -5
- data/vagrant-vbguest.gemspec +2 -1
- metadata +21 -6
- data/files/setup_debian.sh +0 -12
- data/files/setup_linux.sh +0 -4
data/lib/vagrant-vbguest.rb
CHANGED
@@ -11,22 +11,44 @@ module VagrantVbguest
|
|
11
11
|
# by this environment.
|
12
12
|
def execute
|
13
13
|
options = {
|
14
|
+
:_method => :run,
|
15
|
+
:_rebootable => true,
|
14
16
|
:auto_reboot => false
|
15
17
|
}
|
16
18
|
opts = OptionParser.new do |opts|
|
17
|
-
opts.banner = "Usage: vagrant vbguest [vm-name] [
|
19
|
+
opts.banner = "Usage: vagrant vbguest [vm-name] [--do start|rebuild|install] [--status] [-f|--force] [-b|--auto-reboot] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]"
|
18
20
|
opts.separator ""
|
19
21
|
|
20
|
-
opts.on("
|
21
|
-
options[:
|
22
|
+
opts.on("--do COMMAND", [:start, :rebuild, :install], "Manually `start`, `rebuild` or `install` GueastAdditions.") do |command|
|
23
|
+
options[:_method] = command
|
22
24
|
end
|
23
25
|
|
24
|
-
opts.on("--
|
25
|
-
options[:
|
26
|
+
opts.on("--status", "Print current GuestAdditions status and exit.") do
|
27
|
+
options[:_method] = :status
|
28
|
+
options[:_rebootable] = false
|
29
|
+
end
|
30
|
+
|
31
|
+
# opts.on("--start", "Try to start the GuestAdditions servcice manually.") do
|
32
|
+
# options[:_method] = :start
|
33
|
+
# options[:_rebootable] = false
|
34
|
+
# end
|
35
|
+
|
36
|
+
# opts.on("--rebuild", "Rebuild the existing GuestAdditions.") do
|
37
|
+
# options[:_method] = :rebuild
|
38
|
+
# options[:force] = true
|
39
|
+
# end
|
40
|
+
|
41
|
+
# opts.on("--install", "Install GuestAdditions matching your host system.") do
|
42
|
+
# options[:_method] = :install
|
43
|
+
# options[:force] = true
|
44
|
+
# end
|
45
|
+
|
46
|
+
opts.on("-f", "--force", "Whether to force the installation. (Implied by --install and --rebuild)") do
|
47
|
+
options[:force] = true
|
26
48
|
end
|
27
49
|
|
28
|
-
opts.on("--
|
29
|
-
options[:
|
50
|
+
opts.on("--auto-reboot", "-b", "Allow rebooting the VM after installation. (when GuestAdditions won't start)") do
|
51
|
+
options[:auto_reboot] = true
|
30
52
|
end
|
31
53
|
|
32
54
|
opts.on("--no-remote", "-R", "Do not attempt do download the iso file from a webserver") do
|
@@ -40,6 +62,7 @@ module VagrantVbguest
|
|
40
62
|
build_start_options(opts, options)
|
41
63
|
end
|
42
64
|
|
65
|
+
|
43
66
|
argv = parse_options(opts)
|
44
67
|
return if !argv
|
45
68
|
|
@@ -57,10 +80,21 @@ module VagrantVbguest
|
|
57
80
|
|
58
81
|
# Executes a command on a specific VM.
|
59
82
|
def execute_on_vm(vm, options)
|
83
|
+
options = options.clone
|
84
|
+
_method = options.delete(:_method)
|
85
|
+
_rebootable = options.delete(:_rebootable)
|
86
|
+
|
87
|
+
|
60
88
|
options = vm.config.vbguest.to_hash.merge(options)
|
61
|
-
|
62
|
-
|
63
|
-
|
89
|
+
machine = VagrantVbguest::Machine.new(vm, options)
|
90
|
+
status = machine.state
|
91
|
+
vm.ui.send (:ok == status ? :success : :warn), I18n.t("vagrant.plugins.vbguest.status.#{status}", machine.info)
|
92
|
+
|
93
|
+
if _method != :status
|
94
|
+
machine.send(_method)
|
95
|
+
end
|
96
|
+
|
97
|
+
reboot(vm, options) if _rebootable && machine.reboot?
|
64
98
|
end
|
65
99
|
|
66
100
|
def reboot vm, options
|
@@ -69,4 +103,5 @@ module VagrantVbguest
|
|
69
103
|
end
|
70
104
|
end
|
71
105
|
end
|
106
|
+
|
72
107
|
end
|
@@ -8,10 +8,12 @@ module VagrantVbguest
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def reboot(vm, options)
|
11
|
-
if
|
11
|
+
if rebooted?(vm)
|
12
|
+
vm.ui.error(I18n.t("vagrant.plugins.vbguest.restart_loop_guard_activated"))
|
13
|
+
false
|
14
|
+
elsif options[:auto_reboot]
|
12
15
|
vm.ui.warn(I18n.t("vagrant.plugins.vbguest.restart_vm"))
|
13
16
|
@@rebooted[vm.name] = true
|
14
|
-
true
|
15
17
|
else
|
16
18
|
@vm.ui.warn(I18n.t("vagrant.plugins.vbguest.suggest_restart", :name => vm.name))
|
17
19
|
false
|
@@ -46,46 +46,24 @@ module VagrantVbguest
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def initialize(vm, options = {})
|
49
|
+
@vm = vm
|
50
|
+
@options = options
|
51
|
+
@iso_path = nil
|
49
52
|
@env = {
|
50
53
|
:ui => vm.ui,
|
51
54
|
:tmp_path => vm.env.tmp_path
|
52
55
|
}
|
53
|
-
@vm = vm
|
54
|
-
@iso_path = nil
|
55
|
-
@options = options
|
56
|
-
end
|
57
|
-
|
58
|
-
def run!
|
59
|
-
@options[:auto_update] = true
|
60
|
-
run
|
61
|
-
end
|
62
|
-
|
63
|
-
def run
|
64
|
-
return unless @options[:auto_update]
|
65
|
-
|
66
|
-
raise Vagrant::Errors::VMNotCreatedError if !@vm.created?
|
67
|
-
raise Vagrant::Errors::VMInaccessible if !@vm.state == :inaccessible
|
68
|
-
raise Vagrant::Errors::VMNotRunningError if @vm.state != :running
|
69
|
-
|
70
|
-
@vm.ui.success(I18n.t("vagrant.plugins.vbguest.guest_ok", :version => guest_version)) unless needs_update?
|
71
|
-
@vm.ui.warn(I18n.t("vagrant.plugins.vbguest.check_failed", :host => vb_version, :guest => guest_version)) if @options[:no_install]
|
72
|
-
|
73
|
-
if @options[:force] || (!@options[:no_install] && needs_update?)
|
74
|
-
@vm.ui.warn(I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}", :host => vb_version, :guest => guest_version))
|
75
|
-
install
|
76
|
-
end
|
77
|
-
ensure
|
78
|
-
cleanup
|
79
56
|
end
|
80
57
|
|
81
58
|
def install
|
82
59
|
installer = guest_installer
|
83
60
|
raise NoInstallerFoundError, :method => 'install' if !installer
|
84
61
|
|
85
|
-
# @vm.ui.info "Installing using #{installer.class.to_s}"
|
86
62
|
installer.install do |type, data|
|
87
63
|
@vm.ui.info(data, :prefix => false, :new_line => false)
|
88
64
|
end
|
65
|
+
ensure
|
66
|
+
cleanup
|
89
67
|
end
|
90
68
|
|
91
69
|
def rebuild
|
@@ -97,47 +75,31 @@ module VagrantVbguest
|
|
97
75
|
end
|
98
76
|
end
|
99
77
|
|
100
|
-
def
|
78
|
+
def start
|
101
79
|
installer = guest_installer
|
102
|
-
raise NoInstallerFoundError, :method => '
|
80
|
+
raise NoInstallerFoundError, :method => 'manual start' if !installer
|
103
81
|
|
104
|
-
installer.
|
82
|
+
installer.start do |type, data|
|
83
|
+
@vm.ui.info(data, :prefix => false, :new_line => false)
|
84
|
+
end
|
105
85
|
end
|
106
86
|
|
107
|
-
def
|
87
|
+
def guest_version(reload=false)
|
108
88
|
installer = guest_installer
|
109
89
|
raise NoInstallerFoundError, :method => 'check installation of' if !installer
|
110
|
-
|
111
|
-
installer.need_reboot?
|
90
|
+
installer.guest_version(reload)
|
112
91
|
end
|
113
92
|
|
114
|
-
def
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
##
|
119
|
-
#
|
120
|
-
# @return [String] The version code of the VirtualBox Guest Additions
|
121
|
-
# available on the guest, or `nil` if none installed.
|
122
|
-
def guest_version
|
123
|
-
return @guest_version if @guest_version
|
124
|
-
|
125
|
-
guest_version = @vm.driver.read_guest_additions_version
|
126
|
-
guest_version = !guest_version ? nil : guest_version.gsub(/[-_]ose/i, '')
|
127
|
-
|
128
|
-
@vm.channel.sudo('VBoxService --version', :error_check => false) do |type, data|
|
129
|
-
if (v = data.to_s.match(/^(\d+\.\d+.\d+)/)) && guest_version != v[1]
|
130
|
-
@vm.ui.warn(I18n.t("vagrant.plugins.vbguest.guest_version_reports_differ", :driver => guest_version, :service => v[1]))
|
131
|
-
guest_version = v[1]
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
@guest_version = guest_version
|
93
|
+
def host_version
|
94
|
+
installer = guest_installer
|
95
|
+
raise NoInstallerFoundError, :method => 'check installation of' if !installer
|
96
|
+
installer.host_version
|
136
97
|
end
|
137
98
|
|
138
|
-
|
139
|
-
|
140
|
-
|
99
|
+
def running?
|
100
|
+
installer = guest_installer
|
101
|
+
raise NoInstallerFoundError, :method => 'check installation of' if !installer
|
102
|
+
installer.running?
|
141
103
|
end
|
142
104
|
|
143
105
|
# Returns an installer instance for the current vm
|
@@ -146,6 +108,10 @@ module VagrantVbguest
|
|
146
108
|
#
|
147
109
|
# @return [Installers::Base]
|
148
110
|
def guest_installer
|
111
|
+
raise Vagrant::Errors::VMNotCreatedError if !@vm.created?
|
112
|
+
raise Vagrant::Errors::VMInaccessible if !@vm.state == :inaccessible
|
113
|
+
raise Vagrant::Errors::VMNotRunningError if @vm.state != :running
|
114
|
+
|
149
115
|
@guest_installer ||= if @options[:installer].is_a? Class
|
150
116
|
@options[:installer].new(@vm)
|
151
117
|
else
|
@@ -24,7 +24,7 @@ module VagrantVbguest
|
|
24
24
|
false
|
25
25
|
end
|
26
26
|
|
27
|
-
attr_reader :vm
|
27
|
+
attr_reader :vm, :options
|
28
28
|
|
29
29
|
def initialize(vm, options=nil)
|
30
30
|
@vm = vm
|
@@ -60,9 +60,9 @@ module VagrantVbguest
|
|
60
60
|
def install(iso_fileO=nil, opts=nil, &block)
|
61
61
|
end
|
62
62
|
|
63
|
-
# Handels the rebuild of allready
|
63
|
+
# Handels the rebuild of allready running GuestAdditions
|
64
64
|
# It may happen, that the guest has the correct GuestAdditions
|
65
|
-
# version
|
65
|
+
# version running, but not the kernel module is not running.
|
66
66
|
# This method should perform a rebuild or try to reload the
|
67
67
|
# kernel module _without_ the GuestAdditions iso file.
|
68
68
|
# If there is no way of rebuidling or reloading the
|
@@ -77,6 +77,22 @@ module VagrantVbguest
|
|
77
77
|
def rebuild(opts=nil, &block)
|
78
78
|
end
|
79
79
|
|
80
|
+
# Restarts the allready installed GuestAdditions
|
81
|
+
# It may happen, that the guest has the correct GuestAdditions
|
82
|
+
# version installed, but for some reason are not (yet) runnig.
|
83
|
+
# This method should execute the GuestAdditions system specific
|
84
|
+
# init script in order to start it manually.
|
85
|
+
# If there is no way of doing this on a specific system,
|
86
|
+
# this method should left empty.
|
87
|
+
# Subclasses should override this method.
|
88
|
+
#
|
89
|
+
# @param [Hash] opts Optional options Hash wich meight get passed to {Vagrant::Communication::SSH#execute} and firends
|
90
|
+
# @yield [type, data] Takes a Block like {Vagrant::Communication::Base#execute} for realtime output of the command being executed
|
91
|
+
# @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
|
92
|
+
# @yieldparam [String] data Data for the given output.
|
93
|
+
def start(opts=nil, &block)
|
94
|
+
end
|
95
|
+
|
80
96
|
# Determinates if the GuestAdditions kernel module is loaded.
|
81
97
|
# This method tests if there is a working GuestAdditions
|
82
98
|
# kernel module. If there is none, {#rebuild} is beeing called.
|
@@ -86,33 +102,71 @@ module VagrantVbguest
|
|
86
102
|
# Subclasses should override this method.
|
87
103
|
#
|
88
104
|
# @return [Boolean] `true` if the kernel module is loaded (and thus seems to work), `false` otherwise.
|
89
|
-
def
|
105
|
+
def running?(opts=nil, &block)
|
90
106
|
true
|
91
107
|
end
|
92
108
|
|
93
|
-
|
94
|
-
|
109
|
+
# Determinates the GuestAdditions version installed on the
|
110
|
+
# guest system.
|
111
|
+
#
|
112
|
+
# @param [Boolean] reload Whether to read the value again or use
|
113
|
+
# the cached value form an erlier call.
|
114
|
+
# @return [String] The version code of the VirtualBox Guest Additions
|
115
|
+
# available on the guest, or `nil` if none installed.
|
116
|
+
def guest_version(reload=false)
|
117
|
+
return @guest_version if @guest_version && !reload
|
118
|
+
|
119
|
+
guest_version = vm.driver.read_guest_additions_version
|
120
|
+
guest_version = !guest_version ? nil : guest_version.gsub(/[-_]ose/i, '')
|
121
|
+
|
122
|
+
@guest_version = guest_version
|
123
|
+
end
|
124
|
+
|
125
|
+
# Determinates the host's version
|
126
|
+
#
|
127
|
+
# @return [String] The version code of the Virtual Box *host*
|
128
|
+
def host_version
|
129
|
+
vm.driver.version
|
95
130
|
end
|
96
131
|
|
97
|
-
def
|
98
|
-
|
132
|
+
def installer_version(path_to_installer)
|
133
|
+
version = nil
|
134
|
+
@vm.channel.sudo("#{path_to_installer} --info", :error_check => false) do |type, data|
|
135
|
+
if (v = data.to_s.match(/\AIdentification.*\s(\d+\.\d+.\d+)/i))
|
136
|
+
version = v[1]
|
137
|
+
end
|
138
|
+
end
|
139
|
+
version
|
140
|
+
end
|
141
|
+
|
142
|
+
def yield_installation_waring(path_to_installer)
|
143
|
+
@vm.ui.warn I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}",
|
144
|
+
:guest_version => guest_version,
|
145
|
+
:installer_version => installer_version(path_to_installer) || "unknown")
|
146
|
+
end
|
147
|
+
|
148
|
+
def yield_rebuild_warning
|
149
|
+
@vm.ui.warn I18n.t("vagrant.plugins.vbguest.rebuild#{@options[:force] ? '_forced' : ''}",
|
150
|
+
:guest_version => guest_version(true),
|
151
|
+
:host_version => host_version)
|
99
152
|
end
|
100
153
|
|
101
154
|
def iso_file
|
102
155
|
@iso_file ||= begin
|
103
|
-
iso_path =
|
156
|
+
iso_path = options[:iso_path] || local_iso_path
|
104
157
|
|
105
|
-
if !iso_path || iso_path.empty? &&
|
106
|
-
iso_path = VagrantVbguest::Helpers.web_iso_path_for
|
158
|
+
if !iso_path || iso_path.empty? && !options[:no_remote]
|
159
|
+
iso_path = VagrantVbguest::Helpers.web_iso_path_for vm, options
|
107
160
|
end
|
108
161
|
raise VagrantVbguest::IsoPathAutodetectionError if !iso_path || iso_path.empty?
|
109
162
|
|
110
|
-
|
163
|
+
version = host_version
|
164
|
+
iso_path = iso_path.gsub('$VBOX_VERSION', version) % {:version => version}
|
111
165
|
if Vagrant::Downloaders::File.match? iso_path
|
112
166
|
iso_path
|
113
167
|
else
|
114
168
|
# :TODO: This will also raise, if the iso_url points to an invalid local path
|
115
|
-
raise VagrantVbguest::DownloadingDisabledError.new(:from => iso_url) if
|
169
|
+
raise VagrantVbguest::DownloadingDisabledError.new(:from => iso_url) if options[:no_remote]
|
116
170
|
env = {
|
117
171
|
:ui => vm.ui,
|
118
172
|
:tmp_path => vm.env.tmp_path,
|
@@ -125,18 +179,14 @@ module VagrantVbguest
|
|
125
179
|
end
|
126
180
|
end
|
127
181
|
|
128
|
-
def
|
129
|
-
|
182
|
+
def web_iso_path
|
183
|
+
"http://download.virtualbox.org/virtualbox/%{version}/VBoxGuestAdditions_%{version}.iso"
|
130
184
|
end
|
131
185
|
|
132
186
|
def local_iso_path
|
133
187
|
media_manager_iso || guess_iso
|
134
188
|
end
|
135
189
|
|
136
|
-
def web_iso_path
|
137
|
-
"http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso"
|
138
|
-
end
|
139
|
-
|
140
190
|
def media_manager_iso
|
141
191
|
(m = vm.driver.execute('list', 'dvds').match(/^.+:\s+(.*VBoxGuestAdditions.iso)$/i)) && m[1]
|
142
192
|
end
|
@@ -166,8 +216,7 @@ module VagrantVbguest
|
|
166
216
|
# from the guest
|
167
217
|
def cleanup
|
168
218
|
@download.cleanup if @download
|
169
|
-
|
170
|
-
vm.channel.execute("rm #{tmp_path}", :error_check => false) do |type, data|
|
219
|
+
vm.channel.execute("test -f #{tmp_path} && rm #{tmp_path}", :error_check => false) do |type, data|
|
171
220
|
vm.ui.error(data.chomp, :prefix => false)
|
172
221
|
end
|
173
222
|
end
|
@@ -17,7 +17,12 @@ module VagrantVbguest
|
|
17
17
|
end
|
18
18
|
upload(iso_file)
|
19
19
|
vm.channel.sudo("mount #{tmp_path} -o loop #{mount_point}", opts, &block)
|
20
|
-
|
20
|
+
|
21
|
+
installer = File.join(mount_point, 'VBoxLinuxAdditions.run')
|
22
|
+
yield_installation_waring(installer)
|
23
|
+
|
24
|
+
vm.channel.sudo("#{installer} --nox11", opts, &block)
|
25
|
+
|
21
26
|
vm.channel.sudo("umount #{mount_point}", opts, &block)
|
22
27
|
end
|
23
28
|
|
@@ -30,7 +35,7 @@ module VagrantVbguest
|
|
30
35
|
packages = ['linux-headers-`uname -r`']
|
31
36
|
# some Debian system (lenny) dont come with a dkms packe so we neet to skip that.
|
32
37
|
# apt-cache search will exit with 0 even if nothing was found, so we need to grep.
|
33
|
-
packages << '
|
38
|
+
packages << 'dkms' if vm.channel.test('apt-cache search --names-only \'^dkms$\' | grep dkms')
|
34
39
|
packages.join ' '
|
35
40
|
end
|
36
41
|
end
|
@@ -47,17 +47,37 @@ module VagrantVbguest
|
|
47
47
|
vm.channel.sudo("umount #{mount_point}", opts, &block)
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
50
|
+
def running?(opts=nil, &block)
|
51
51
|
opts = {
|
52
52
|
:sudo => true
|
53
53
|
}.merge(opts || {})
|
54
54
|
vm.channel.test('lsmod | grep vboxsf', opts, &block)
|
55
55
|
end
|
56
56
|
|
57
|
+
# @return [String] The version code of the VirtualBox Guest Additions
|
58
|
+
# available on the guest, or `nil` if none installed.
|
59
|
+
def guest_version(reload = false)
|
60
|
+
return @guest_version if @guest_version && !reload
|
61
|
+
driver_version = super
|
62
|
+
|
63
|
+
@vm.channel.sudo('VBoxService --version', :error_check => false) do |type, data|
|
64
|
+
if (v = data.to_s.match(/^(\d+\.\d+.\d+)/)) && driver_version != v[1]
|
65
|
+
@vm.ui.warn(I18n.t("vagrant.plugins.vbguest.guest_version_reports_differ", :driver => driver_version, :service => v[1]))
|
66
|
+
@guest_version = v[1]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
57
72
|
def rebuild(opts=nil, &block)
|
58
73
|
vm.channel.sudo('/etc/init.d/vboxadd setup', opts, &block)
|
59
74
|
end
|
60
75
|
|
76
|
+
def start(opts=nil, &block)
|
77
|
+
opts = {:error_check => false}.merge(opts || {})
|
78
|
+
vm.channel.sudo('/etc/init.d/vboxadd start', opts, &block)
|
79
|
+
end
|
80
|
+
|
61
81
|
end
|
62
82
|
end
|
63
83
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module VagrantVbguest
|
2
|
+
class Machine
|
3
|
+
|
4
|
+
require 'micromachine'
|
5
|
+
|
6
|
+
attr_reader :installer, :vm, :options
|
7
|
+
|
8
|
+
def initialize vm, options
|
9
|
+
@vm = vm
|
10
|
+
@options = options
|
11
|
+
@installer = Installer.new @vm, @options
|
12
|
+
|
13
|
+
@ga_machine = MicroMachine.new :pending
|
14
|
+
@ga_machine.when :install, :pending => :installed
|
15
|
+
@ga_machine.when :start, :pending => :started
|
16
|
+
@ga_machine.when :rebuild, :pending => :rebuilt, :started => :rebuilt
|
17
|
+
|
18
|
+
@ga_machine.on(:installed) { installer.install }
|
19
|
+
@ga_machine.on(:started) { installer.start }
|
20
|
+
@ga_machine.on(:rebuilt) { installer.rebuild }
|
21
|
+
|
22
|
+
@box_machine = MicroMachine.new :first_boot
|
23
|
+
@box_machine.when :reboot, :first_boot => :rebooted
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
runlist = steps
|
28
|
+
current_state = state
|
29
|
+
while (command = runlist.shift)
|
30
|
+
self.send(command)
|
31
|
+
return run if current_state != state
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def install
|
36
|
+
return @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.skiped_installation")) if options[:no_install] && !options[:force]
|
37
|
+
@ga_machine.trigger :install
|
38
|
+
end
|
39
|
+
|
40
|
+
def rebuild
|
41
|
+
return @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.skiped_rebuild")) if options[:no_install] && !options[:force]
|
42
|
+
@ga_machine.trigger :rebuild
|
43
|
+
end
|
44
|
+
|
45
|
+
def start
|
46
|
+
@ga_machine.trigger :start
|
47
|
+
end
|
48
|
+
|
49
|
+
def installation_ran?; @ga_machine == :installed end
|
50
|
+
def started?; @ga_machine == :started end
|
51
|
+
def rebuilt?; @ga_machine == :rebuilt end
|
52
|
+
|
53
|
+
def reboot; @box_machine.trigger :reboot end
|
54
|
+
def reboot?; @box_machine.state == :rebooted end
|
55
|
+
|
56
|
+
def steps
|
57
|
+
case state
|
58
|
+
when :clean, :unmatched
|
59
|
+
[:install]
|
60
|
+
when :not_running
|
61
|
+
installation_ran? ? [:reboot] : [:start, :rebuild, :reboot]
|
62
|
+
else
|
63
|
+
[]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def state
|
68
|
+
guest_version = installer.guest_version(true)
|
69
|
+
|
70
|
+
return :clean if !guest_version
|
71
|
+
return :unmatched if installer.host_version != guest_version
|
72
|
+
return :not_running if !installer.running?
|
73
|
+
return :ok
|
74
|
+
end
|
75
|
+
|
76
|
+
def info
|
77
|
+
{
|
78
|
+
:host_version => installer.host_version,
|
79
|
+
:guest_version => installer.guest_version
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -15,17 +15,13 @@ module VagrantVbguest
|
|
15
15
|
|
16
16
|
def call(env)
|
17
17
|
options = @vm.config.vbguest.to_hash
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
else
|
25
|
-
reboot(@vm, options)
|
26
|
-
end
|
18
|
+
if options[:auto_update]
|
19
|
+
machine = VagrantVbguest::Machine.new @vm, options
|
20
|
+
status = machine.state
|
21
|
+
@vm.ui.send (:ok == status ? :success : :warn), I18n.t("vagrant.plugins.vbguest.status.#{status}", machine.info)
|
22
|
+
machine.run
|
23
|
+
reboot(@vm, options) if machine.reboot?
|
27
24
|
end
|
28
|
-
|
29
25
|
@app.call(env)
|
30
26
|
end
|
31
27
|
|
data/locales/en.yml
CHANGED
@@ -2,12 +2,13 @@ en:
|
|
2
2
|
vagrant:
|
3
3
|
plugins:
|
4
4
|
vbguest:
|
5
|
-
|
6
|
-
|
7
|
-
installing: "Installing Virtualbox Guest Additions %{
|
8
|
-
installing_forced: "Forcing installation of Virtualbox Guest Additions %{
|
5
|
+
skiped_installation: "Updating GuestAdditions skipped."
|
6
|
+
skiped_rebuild: "Rebuilding GuestAdditions skipped."
|
7
|
+
installing: "Installing Virtualbox Guest Additions %{installer_version} - guest's version is %{guest_version}"
|
8
|
+
installing_forced: "Forcing installation of Virtualbox Guest Additions %{installer_version} - guest's version is %{guest_version}"
|
9
|
+
rebuild: "Rebuilding Virtualbox Guest Additions %{guest_version} (Your host's version is %{host_version})"
|
10
|
+
rebuild_forced: "Forcing rebuilding of Virtualbox Guest Additions %{guest_version} (Your host's version is %{host_version})"
|
9
11
|
start_copy_iso: "Copy iso file %{from} into the box %{to}"
|
10
|
-
start_copy_script: "Copy installer file %{from} into the box %{to}"
|
11
12
|
restart_vm: "Restarting VM to apply changes..."
|
12
13
|
suggest_restart: "Guest Additions got installed. However, they seem not be loaded correctly. Please restart the box runing `vagrant reload %{name}`"
|
13
14
|
restart_loop_guard_activated: "Guest Additions will not load, even after reboot."
|
@@ -17,6 +18,12 @@ en:
|
|
17
18
|
VBoxService inside the vm claims: %{service}
|
18
19
|
Going on, assuming VBoxService is correct...
|
19
20
|
|
21
|
+
status:
|
22
|
+
clean: "No installation found."
|
23
|
+
unmatched: "GuestAdditions versions on your host (%{host_version}) and guest (%{guest_version}) does not match."
|
24
|
+
not_running: "GuestAdditions seems to be installed (%{guest_version}) correctly, but don't run."
|
25
|
+
ok: "GuestAdditions %{guest_version} running --- OK."
|
26
|
+
|
20
27
|
errors:
|
21
28
|
autodetect_iso_path: |-
|
22
29
|
Could not autodetect a local of the Virtualbox Guest Additions iso file.
|
data/vagrant-vbguest.gemspec
CHANGED
@@ -19,8 +19,9 @@ Gem::Specification.new do |s|
|
|
19
19
|
# specify any dependencies here; for example:
|
20
20
|
# s.add_development_dependency "rspec"
|
21
21
|
# s.add_runtime_dependency "rest-client"
|
22
|
+
s.add_runtime_dependency "micromachine"
|
22
23
|
|
23
|
-
s.add_development_dependency "bundler", ">= 1.
|
24
|
+
s.add_development_dependency "bundler", ">= 1.2.0"
|
24
25
|
|
25
26
|
s.files = `git ls-files`.split("\n")
|
26
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-vbguest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0.
|
4
|
+
version: 0.6.0.pre2
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: micromachine
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: bundler
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -18,7 +34,7 @@ dependencies:
|
|
18
34
|
requirements:
|
19
35
|
- - ! '>='
|
20
36
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
37
|
+
version: 1.2.0
|
22
38
|
type: :development
|
23
39
|
prerelease: false
|
24
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +42,7 @@ dependencies:
|
|
26
42
|
requirements:
|
27
43
|
- - ! '>='
|
28
44
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
45
|
+
version: 1.2.0
|
30
46
|
description: A Vagrant plugin which automatically installs the host's VirtualBox Guest
|
31
47
|
Additions on the guest system.
|
32
48
|
email:
|
@@ -41,8 +57,6 @@ files:
|
|
41
57
|
- LICENSE
|
42
58
|
- Rakefile
|
43
59
|
- Readme.md
|
44
|
-
- files/setup_debian.sh
|
45
|
-
- files/setup_linux.sh
|
46
60
|
- lib/vagrant-vbguest.rb
|
47
61
|
- lib/vagrant-vbguest/command.rb
|
48
62
|
- lib/vagrant-vbguest/config.rb
|
@@ -54,6 +68,7 @@ files:
|
|
54
68
|
- lib/vagrant-vbguest/installers/debian.rb
|
55
69
|
- lib/vagrant-vbguest/installers/linux.rb
|
56
70
|
- lib/vagrant-vbguest/installers/ubuntu.rb
|
71
|
+
- lib/vagrant-vbguest/machine.rb
|
57
72
|
- lib/vagrant-vbguest/middleware.rb
|
58
73
|
- lib/vagrant-vbguest/version.rb
|
59
74
|
- lib/vagrant_init.rb
|
data/files/setup_debian.sh
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
function do_install {
|
3
|
-
apt-get install -y linux-headers-`uname -r` dkms
|
4
|
-
}
|
5
|
-
|
6
|
-
do_install || (apt-get update && do_install) || exit 1
|
7
|
-
|
8
|
-
mount /tmp/VBoxGuestAdditions.iso -o loop /mnt
|
9
|
-
/mnt/VBoxLinuxAdditions.run --nox11
|
10
|
-
umount /mnt
|
11
|
-
|
12
|
-
exit 0
|
data/files/setup_linux.sh
DELETED