vagrant-serial 0.0.12 → 0.0.13

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.
@@ -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 #{ENV['HOME']}/serial/socat.#{env[:vm].uuid}-com1.pid --exec /usr/bin/socat && rm #{ENV['HOME']}/serial/socat.#{env[:vm].uuid}-com1.pid`
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 #{ENV['HOME']}/serial/socat.#{env[:vm].uuid}-com2.pid --exec /usr/bin/socat && rm #{ENV['HOME']}/serial/socat.#{env[:vm].uuid}-com2.pid`
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", "#{ENV['HOME']}/serial/#{env[:vm].uuid}-com1"]
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", "#{ENV['HOME']}/serial/#{env[:vm].uuid}-com2"]
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 #{ENV['HOME']}/serial/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['HOME']}/serial/#{env[:vm].uuid}-com1`
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 #{ENV['HOME']}/serial/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['HOME']}/serial/#{env[:vm].uuid}-com2`
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)
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Serial
3
- VERSION = "0.0.12"
3
+ VERSION = "0.0.13"
4
4
  end
5
5
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-serial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: