vagrant-mountcommand 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +24 -0
- data/lib/vagrant-mountcommand/action.rb +43 -0
- data/lib/vagrant-mountcommand/config.rb +22 -0
- data/lib/vagrant-mountcommand/errors.rb +6 -0
- data/lib/vagrant-mountcommand/plugin.rb +23 -0
- data/lib/vagrant-mountcommand/version.rb +5 -0
- data/lib/vagrant-mountcommand.rb +20 -0
- data/locales/en.yml +8 -0
- data/vagrant-mountcommand.gemspec +22 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Brendan Tobolaski
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
vagrant-mount-command
|
2
|
+
=====================
|
3
|
+
|
4
|
+
A vagrant plugin that runs a command after all of your vagrant mounts have mounted.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Run `vagrant plugin install vagrant-mountcommand`
|
9
|
+
|
10
|
+
## Configuration
|
11
|
+
|
12
|
+
You can add lines by adding `config.mount_commands.command "command"`. The
|
13
|
+
command will be run using sudo, so there is no need for you to prefix the
|
14
|
+
command with sudo.
|
15
|
+
|
16
|
+
## Notes
|
17
|
+
|
18
|
+
- This wont run on the first vagrant up
|
19
|
+
- This is because it runs before any provisioning has happened, so your command is unlikely to be succesfull.
|
20
|
+
|
21
|
+
As of right now, this plugin is pretty rough. It works for my particular
|
22
|
+
problem, but its fairly shaky. If you would like to use this, go ahead, but it
|
23
|
+
may take some work for you to get it working. If, in that process you notice
|
24
|
+
or fix a problem I would really appriciate a pull request or at least an issue.
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module MountCommand
|
3
|
+
module Action
|
4
|
+
class Command
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
@env = env
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
@app.call(env)
|
12
|
+
@env = env
|
13
|
+
|
14
|
+
@machine = env[:machine]
|
15
|
+
|
16
|
+
# Setup a sentinel to check whether the machine has already been provisioned.
|
17
|
+
sentinel = env[:machine].data_dir.join("action_provision")
|
18
|
+
run_mount_commands = true
|
19
|
+
if sentinel.file?
|
20
|
+
timestamp = sentinel.open('rb').read
|
21
|
+
if Integer(timestamp) + 60 > Time.now.to_i
|
22
|
+
run_mount_commands = false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if run_mount_commands and !mount_commands.empty?
|
27
|
+
mount_command
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def mount_commands
|
32
|
+
@machine.config.mount_commands.commands
|
33
|
+
end
|
34
|
+
|
35
|
+
def mount_command
|
36
|
+
mount_commands.each do |command|
|
37
|
+
@machine.communicate.sudo(command)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module MountCommand
|
3
|
+
class Config < Vagrant.plugin('2', :config)
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@__mount_commands = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def commands
|
10
|
+
@__mount_commands
|
11
|
+
end
|
12
|
+
|
13
|
+
def command(command_to_run)
|
14
|
+
@__mount_commands.push command_to_run
|
15
|
+
end
|
16
|
+
|
17
|
+
def merge(other)
|
18
|
+
@__mount_commands.concat(other.instance_variable_get(:@__mount_commands))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module MountCommand
|
3
|
+
class Plugin < Vagrant.plugin("2")
|
4
|
+
name "MountCommand"
|
5
|
+
description <<-DESC
|
6
|
+
This plugin gives you the ability to run a command after vagrant mounts
|
7
|
+
your shared directories
|
8
|
+
DESC
|
9
|
+
|
10
|
+
config(:mount_commands) do
|
11
|
+
require_relative 'config'
|
12
|
+
Config
|
13
|
+
end
|
14
|
+
|
15
|
+
require_relative 'action'
|
16
|
+
%w{up reload}.each do |action|
|
17
|
+
action_hook(:MountCommand, "machine_action_#{action}".to_sym) do |hook|
|
18
|
+
hook.before(Vagrant::Action::Builtin::NFS, Action::Command)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant mount-command plugin must be run within Vagrant"
|
5
|
+
end
|
6
|
+
|
7
|
+
require "vagrant-mountcommand/plugin"
|
8
|
+
require "vagrant-mountcommand/version"
|
9
|
+
require "vagrant-mountcommand/errors"
|
10
|
+
|
11
|
+
module VagrantPlugins
|
12
|
+
module MountCommand
|
13
|
+
def self.source_root
|
14
|
+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
15
|
+
end
|
16
|
+
|
17
|
+
I18n.load_path << File.expand_path('locales/en.yml', source_root)
|
18
|
+
I18n.reload!
|
19
|
+
end
|
20
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "vagrant-mountcommand"
|
7
|
+
s.version = "0.0.1"
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Brendan Tobolaski"]
|
10
|
+
s.email = ["brendan@tobolaski.com"]
|
11
|
+
s.homepage = "https://github.com/btobolaski/vagrant-mountcommand"
|
12
|
+
s.summary = %q{Runs a command after all of vagrant's share mounts have been mounted}
|
13
|
+
s.description = %q{a vagrant plugin to run a command after vagrant mounts all of the shares, every time the vm boots}
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.rubyforge_project = "vagrant-mountcommand"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-mountcommand
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Brendan Tobolaski
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2013-10-15 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: a vagrant plugin to run a command after vagrant mounts all of the shares, every time the vm boots
|
22
|
+
email:
|
23
|
+
- brendan@tobolaski.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
- lib/vagrant-mountcommand.rb
|
36
|
+
- lib/vagrant-mountcommand/action.rb
|
37
|
+
- lib/vagrant-mountcommand/config.rb
|
38
|
+
- lib/vagrant-mountcommand/errors.rb
|
39
|
+
- lib/vagrant-mountcommand/plugin.rb
|
40
|
+
- lib/vagrant-mountcommand/version.rb
|
41
|
+
- locales/en.yml
|
42
|
+
- vagrant-mountcommand.gemspec
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: https://github.com/btobolaski/vagrant-mountcommand
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project: vagrant-mountcommand
|
69
|
+
rubygems_version: 1.3.6
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Runs a command after all of vagrant's share mounts have been mounted
|
73
|
+
test_files: []
|
74
|
+
|