vagrant-serial 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vagrant-serial/config.rb +5 -0
- data/lib/vagrant-serial/middleware/clear_forwarded_ports.rb +4 -2
- data/lib/vagrant-serial/middleware/configure_ports.rb +4 -2
- data/lib/vagrant-serial/middleware/forward_ports.rb +4 -2
- data/lib/vagrant-serial/version.rb +1 -1
- data/lib/vagrant-serial.rb +2 -0
- metadata +1 -1
@@ -3,6 +3,11 @@ module Vagrant
|
|
3
3
|
class Config < Vagrant::Config::Base
|
4
4
|
attr_accessor :forward_com1
|
5
5
|
attr_accessor :forward_com2
|
6
|
+
attr_accessor :sockets_path
|
7
|
+
|
8
|
+
def sockets_path
|
9
|
+
@sockets_path.nil? ? (@sockets_path = "#{ENV["VAGRANT_HOME"]}/serial") : @sockets_path
|
10
|
+
end
|
6
11
|
|
7
12
|
def validate(env, errors)
|
8
13
|
errors.add("Host port for com1 forwarding couldn't be below 1024.") if forward_com1 && forward_com1.to_i < 1024
|
@@ -7,12 +7,14 @@ module Vagrant
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
+
FileUtils.mkdir_p(env[:vm].config.sockets_path) if !File.directory?(env[:vm].config.sockets_path)
|
11
|
+
|
10
12
|
if env[:vm].config.serial.forward_com1
|
11
|
-
`/sbin/start-stop-daemon --stop --quiet --pidfile #{
|
13
|
+
`/sbin/start-stop-daemon --stop --quiet --pidfile #{env[:vm].config.sockets_path}/socat.#{env[:vm].uuid}-com1.pid --exec /usr/bin/socat && rm #{env[:vm].config.sockets_path}/socat.#{env[:vm].uuid}-com1.pid`
|
12
14
|
end
|
13
15
|
|
14
16
|
if env[:vm].config.serial.forward_com2
|
15
|
-
`/sbin/start-stop-daemon --stop --quiet --pidfile #{
|
17
|
+
`/sbin/start-stop-daemon --stop --quiet --pidfile #{env[:vm].config.sockets_path}/socat.#{env[:vm].uuid}-com2.pid --exec /usr/bin/socat && rm #{env[:vm].config.sockets_path}/socat.#{env[:vm].uuid}-com2.pid`
|
16
18
|
end
|
17
19
|
|
18
20
|
@app.call(env)
|
@@ -7,13 +7,15 @@ module Vagrant
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
+
FileUtils.mkdir_p(env[:vm].config.sockets_path) if !File.directory?(env[:vm].config.sockets_path)
|
11
|
+
|
10
12
|
if env[:vm].config.serial.forward_com1
|
11
|
-
command = ["modifyvm", env[:vm].uuid, "--uart1", "0x3F8", "4", "--uartmode1", "server", "#{
|
13
|
+
command = ["modifyvm", env[:vm].uuid, "--uart1", "0x3F8", "4", "--uartmode1", "server", "#{env[:vm].config.sockets_path}/#{env[:vm].uuid}-com1"]
|
12
14
|
env[:vm].driver.execute_command(command)
|
13
15
|
end
|
14
16
|
|
15
17
|
if env[:vm].config.serial.forward_com2
|
16
|
-
command = ["modifyvm", env[:vm].uuid, "--uart2", "0x2F8", "3", "--uartmode2", "server", "#{
|
18
|
+
command = ["modifyvm", env[:vm].uuid, "--uart2", "0x2F8", "3", "--uartmode2", "server", "#{env[:vm].config.sockets_path}/#{env[:vm].uuid}-com2"]
|
17
19
|
env[:vm].driver.execute_command(command)
|
18
20
|
end
|
19
21
|
|
@@ -7,12 +7,14 @@ module Vagrant
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
+
FileUtils.mkdir_p(env[:vm].config.sockets_path) if !File.directory?(env[:vm].config.sockets_path)
|
11
|
+
|
10
12
|
if env[:vm].config.serial.forward_com1
|
11
|
-
`/sbin/start-stop-daemon --quiet --start --pidfile #{
|
13
|
+
`/sbin/start-stop-daemon --quiet --start --pidfile #{env[:vm].config.sockets_path}/socat.#{env[:vm].uuid}-com1.pid --background --make-pidfile --exec /usr/bin/socat -- tcp-l:#{env[:vm].config.serial.forward_com1},reuseaddr,fork UNIX-CONNECT:#{env[:vm].config.sockets_path}/#{env[:vm].uuid}-com1`
|
12
14
|
end
|
13
15
|
|
14
16
|
if env[:vm].config.serial.forward_com2
|
15
|
-
`/sbin/start-stop-daemon --quiet --start --pidfile #{
|
17
|
+
`/sbin/start-stop-daemon --quiet --start --pidfile #{env[:vm].config.sockets_path}/socat.#{env[:vm].uuid}-com2.pid --background --make-pidfile --exec /usr/bin/socat -- tcp-l:#{env[:vm].config.serial.forward_com2},reuseaddr,fork UNIX-CONNECT:#{env[:vm].config.sockets_path}/#{env[:vm].uuid}-com2`
|
16
18
|
end
|
17
19
|
|
18
20
|
@app.call(env)
|
data/lib/vagrant-serial.rb
CHANGED
@@ -5,6 +5,8 @@ require "vagrant-serial/middleware/configure_ports"
|
|
5
5
|
require "vagrant-serial/middleware/forward_ports"
|
6
6
|
require "vagrant-serial/middleware/clear_forwarded_ports"
|
7
7
|
|
8
|
+
require "fileutils"
|
9
|
+
|
8
10
|
Vagrant.config_keys.register(:serial) { Vagrant::Serial::Config }
|
9
11
|
|
10
12
|
Vagrant.actions[:start].insert_after Vagrant::Action::VM::Customize, Vagrant::Serial::Middleware::ConfigurePorts
|