Skip to content
This repository
Browse code

initial

  • Loading branch information...
commit b3b12d9dfdee6dbee766d908d6a646bbd6a12118 0 parents
Robert Schulze authored September 06, 2011
4  .gitignore
... ...
@@ -0,0 +1,4 @@
  1
+*.gem
  2
+.bundle
  3
+Gemfile.lock
  4
+pkg/*
8  Gemfile
... ...
@@ -0,0 +1,8 @@
  1
+source "http://rubygems.org"
  2
+
  3
+# Specify your gem's dependencies in vagrant-rake.gemspec
  4
+# gem "vagrant-vbguest", :path => "."
  5
+# 
  6
+# gem "vagrant", "~> 0.8.0"
  7
+
  8
+gemspec
1  Rakefile
... ...
@@ -0,0 +1 @@
  1
+require "bundler/gem_tasks"
11  lib/vagrant-vbguest.rb
... ...
@@ -0,0 +1,11 @@
  1
+require 'vagrant'
  2
+require "vagrant-vbguest/config"
  3
+require 'vagrant-vbguest/command'
  4
+require 'vagrant-vbguest/middleware'
  5
+
  6
+vbguest = Vagrant::Action::Builder.new do
  7
+  use VagrantVbguest::Middleware
  8
+end
  9
+
  10
+Vagrant::Action.register(:vbguest, vbguest)
  11
+
19  lib/vagrant-vbguest/command.rb
... ...
@@ -0,0 +1,19 @@
  1
+module VagrantVbguest
  2
+  
  3
+  class Command < Vagrant::Command::Base
  4
+    register "vbguest", "Check and Update the VirtualBox Guest Additions"
  5
+
  6
+    # Executes the given rake command on the VMs that are represented
  7
+    # by this environment.
  8
+    def execute
  9
+      target_vms.each { |vm| execute_on_vm(vm) }
  10
+    end
  11
+
  12
+    protected
  13
+
  14
+    # Executes a command on a specific VM.
  15
+    def execute_on_vm(vm)
  16
+      vm.env.actions.run(:vbguest)
  17
+    end
  18
+  end
  19
+end
9  lib/vagrant-vbguest/config.rb
... ...
@@ -0,0 +1,9 @@
  1
+module VagrantVbguest
  2
+  
  3
+  class Config < Vagrant::Config::Base
  4
+    configures :vbguest
  5
+    attr_accessor :iso_path
  6
+    
  7
+  end
  8
+  
  9
+end
40  lib/vagrant-vbguest/middleware.rb
... ...
@@ -0,0 +1,40 @@
  1
+module VagrantVbguest
  2
+  
  3
+  # A Vagrant middleware which checks the installed VirtualBox Guest
  4
+  # Additions to match the installed VirtualBox installation on the 
  5
+  # host system.
  6
+  
  7
+  class Middleware
  8
+    def initialize(app, env)
  9
+      @app = app
  10
+      @env = env
  11
+    end
  12
+
  13
+    def call(env)
  14
+      
  15
+      version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
  16
+      needs_update = version.empty? || (VirtualBox.version != version.gsub(/[-_]ose/i, ''))
  17
+
  18
+      env.ui.warn("Need update/install to version: #{VirtualBox.version}")
  19
+      
  20
+      if env["vm"].created? && env["vm"].vm.running?
  21
+        command = "echo #{VirtualBox.version} > /home/vagrant/vbupgrade".strip
  22
+
  23
+        env["vm"].ssh.execute do |ssh|
  24
+          ssh.exec!("#{command}") do |channel, type, data|
  25
+            # Print the data directly to STDOUT, not doing any newlines
  26
+            # or any extra formatting of our own
  27
+            $stdout.print(data) if type != :exit_status
  28
+          end
  29
+
  30
+          # Puts out an ending newline just to make sure we end on a new
  31
+          # line.
  32
+          $stdout.puts
  33
+        end
  34
+      end
  35
+
  36
+      @app.call(env)
  37
+    end
  38
+  end
  39
+end
  40
+
3  lib/vagrant-vbguest/version.rb
... ...
@@ -0,0 +1,3 @@
  1
+module VagrantVbguest
  2
+  VERSION = "0.0.1"
  3
+end
3  lib/vagrant_init.rb
... ...
@@ -0,0 +1,3 @@
  1
+# This file is automatically loaded by Vagrant to load any
  2
+# plugins. This file kicks off this plugin.
  3
+require 'vagrant-vbguest'
5  locales/en.yml
... ...
@@ -0,0 +1,5 @@
  1
+en:
  2
+  vagrant:
  3
+    plugins:
  4
+      vbguest:
  5
+        installing: "Installing Virtualbox Guest Additions %{version}"
31  vagrant-vbguest.gemspec
... ...
@@ -0,0 +1,31 @@
  1
+# -*- encoding: utf-8 -*-
  2
+$:.push File.expand_path("../lib", __FILE__)
  3
+require "vagrant-vbguest/version"
  4
+
  5
+Gem::Specification.new do |s|
  6
+  s.name        = "vagrant-vbguest"
  7
+  s.version     = VagrantVbguest::VERSION
  8
+  s.platform    = Gem::Platform::RUBY
  9
+  s.authors     = ["Robert Schulze"]
  10
+  s.email       = ["robert@dotless.de"]
  11
+  #s.homepage    = "http://rubygems.org/gems/vagrant-vbguest"
  12
+  s.summary     = %q{A Vagrant plugin to install the VirtualBoxAdditions into the VM}
  13
+  s.description = %q{A Vagrant plugin to install the VirtualBoxAdditions into the VM}
  14
+
  15
+  s.required_rubygems_version = ">= 1.3.6"
  16
+  #s.rubyforge_project = "vagrant-vbguest"
  17
+  
  18
+  # specify any dependencies here; for example:
  19
+  # s.add_development_dependency "rspec"
  20
+  # s.add_runtime_dependency "rest-client"
  21
+  
  22
+  s.add_dependency "virtualbox", "~> 0.9.1"
  23
+  s.add_dependency "vagrant", "~> 0.8.2"
  24
+  s.add_development_dependency "bundler", ">= 1.0.0"
  25
+  
  26
+  s.files         = `git ls-files`.split("\n")
  27
+  s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
  28
+  s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
  29
+  s.require_paths = ["lib"]
  30
+
  31
+end

0 notes on commit b3b12d9

Please sign in to comment.
Something went wrong with that request. Please try again.