vagrant-rlogin 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c76ed5db89c7d0d9b0c1b21e0623d296dd6be50
4
+ data.tar.gz: 3602418adebf06e0f7e8552ac274f139f035459c
5
+ SHA512:
6
+ metadata.gz: 3048061e3a2ea530e2455951503115ceb8abe22d392cbba2fcf344612a09551db8f5bc5a1d40983f653d35ad56d52f6196d463bddef2413f78b9f37f1344e39c
7
+ data.tar.gz: 95a07d37e62068adef4831832195f593c299a2037681ada48fab92366dbab2d74e134c3d165e84a40ca9785d9b5d03696a8bca250f6fb28371d2f16a22afd57c
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /pkg/
2
+ /Gemfile.lock
3
+ Vagrantfile
4
+ /.vagrant/
5
+ *.log
6
+ teraterm.ini
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
7
+ end
8
+
9
+ group :plugins do
10
+ gem "vagrant-rlogin", path: "."
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Toshiyuki Goto
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Vagrant RLogin Plugin
2
+
3
+ This is a Vagrant plugin that enables to ssh into vm with RLogin.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ vagrant plugin install vagrant-rlogin
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ vagrant rlogin
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ ```ruby
20
+ Vagrant.configure(2) do |config|
21
+ # ...
22
+ config.rlogin.exe_path = 'C:\Program Files (x86)\RLogin\RLogin.exe'
23
+ config.rlogin.config_path = 'C:\Users\username\.vagrant.d\rlogin.rlg'
24
+ # ...
25
+ end
26
+ ```
27
+
28
+ * ```exe_path``` A RLogin.exe file path. We will find real path
29
+ * If set and executable, use it.
30
+ * If set and not executable, search in PATH.
31
+ * If not set, search "RLogin.exe" in PATH.
32
+ * If not found in PATH, use 'C:\Program Files (x86)\RLogin\RLogin.exe'
33
+ or 'C:\Program Files\RLogin\RLogin.exe'
34
+ * ```config_path``` Template filename of the RLogin configuration file
35
+
36
+ ## Thanks
37
+
38
+ Vagrant ( https://github.com/https://github.com/mitchellh/vagrant )
39
+ vagrant-multi-putty ( https://github.com/nickryand/vagrant-multi-putty )
40
+ vagrant-teraterm ( https://github.com/tiibun/vagrant-teraterm )
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ # Immediately sync all stdout so that tools like buildbot can
5
+ # immediately load in the output.
6
+ $stdout.sync = true
7
+ $stderr.sync = true
8
+
9
+ # Change to the directory of this file.
10
+ Dir.chdir(File.expand_path("../", __FILE__))
11
+
12
+ # This installs the tasks that help with gem creation and
13
+ # publishing.
14
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,6 @@
1
+ require "vagrant-rlogin/version"
2
+ require "vagrant-rlogin/plugin"
3
+
4
+ module VagrantRLogin
5
+
6
+ end
@@ -0,0 +1,110 @@
1
+ require('optparse')
2
+ require('pathname')
3
+
4
+ module VagrantRLogin
5
+ class Command < Vagrant.plugin(2, :command)
6
+ def self.synopsis
7
+ "connects to machine via SSH using RLogin"
8
+ end
9
+
10
+ def execute
11
+ opts = OptionParser.new do |opts|
12
+ opts.banner = "Usage: vagrant rlogin [vm-name...]"
13
+
14
+ opts.separator ""
15
+ end
16
+
17
+ argv = parse_options(opts)
18
+ return -1 if !argv
19
+
20
+ with_target_vms(argv, single_target: true) do |vm|
21
+ @config = vm.config.rlogin
22
+
23
+ ssh_info = vm.ssh_info
24
+ @logger.debug("ssh_info is #{ssh_info}")
25
+ # If ssh_info is nil, the machine is not ready for ssh.
26
+ raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
27
+
28
+ exe_path = find_exe_path(@config.exe_path)
29
+ return -1 if !exe_path
30
+
31
+ commands = [
32
+ exe_path,
33
+ "/ssh",
34
+ "/ip", ssh_info[:host],
35
+ "/port", ssh_info[:port],
36
+ "/user", ssh_info[:username],
37
+ "/inuse",
38
+ ]
39
+
40
+ if not generate_rlogin_config(commands, vm)
41
+ return -1
42
+ end
43
+
44
+ @logger.debug(commands)
45
+ do_process(commands)
46
+ end
47
+ end
48
+
49
+ def find_exe_path(path)
50
+ if not path.nil?
51
+ return path if File.executable?(path)
52
+
53
+ # search in PATH
54
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |p|
55
+ _p = Pathname(p) + path
56
+ return _p.to_s if _p.executable?
57
+ end
58
+ else
59
+ # search in PATH
60
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |p|
61
+ _p = Pathname(p) + 'RLogin.exe'
62
+ return _p.to_s if _p.executable?
63
+ end
64
+
65
+ # Program Files
66
+ ['C:\Program Files (x86)\RLogin\RLogin.exe',
67
+ 'C:\Program Files\RLogin\RLogin.exe'].each do |p|
68
+ return p if File.executable?(p)
69
+ end
70
+ end
71
+
72
+ @env.ui.error("File is not found or executable. => #{path}")
73
+ nil
74
+ end
75
+
76
+ def absolute_winpath(vm, path)
77
+ p = Pathname(path)
78
+ return path.gsub(/\//, "\\") if p.absolute?
79
+ return Pathname(vm.env.root_path).join(p).to_s.gsub(/\//, "\\")
80
+ end
81
+
82
+ def generate_rlogin_config(commands, vm)
83
+
84
+ src = @config.config_path
85
+ if src.nil?
86
+ @env.ui.error("config_path notfound in rlogin config")
87
+ nil
88
+ end
89
+
90
+ ssh_info = vm.ssh_info
91
+ content = File.read(src)
92
+
93
+ if ssh_info.include?(:password)
94
+ commands << "/pass" << ssh_info[:password]
95
+ elsif ssh_info.include?(:private_key_path)
96
+ key = vm.ssh_info[:private_key_path][0]
97
+ content.gsub!(/^Entry.IdKey=.*?$/, "Entry.IdKey=\"#{key}\";")
98
+ end
99
+
100
+ dst = File.join(vm.data_dir, "rlogin.rlg")
101
+ File.write(dst, content)
102
+ commands << dst
103
+ end
104
+
105
+ def do_process(commands)
106
+ pid = spawn(commands.join(" "))
107
+ Process.detach(pid)
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,27 @@
1
+ module VagrantRLogin
2
+ class Config < Vagrant.plugin(2, :config)
3
+ # Program file absolute path or command name if found in PATH.
4
+ # If value is undefined, search
5
+ # RLogin.exe
6
+ # C:\Program Files (x86)\RLogin\RLogin.exe
7
+ # C:\Program Files\RLogin\RLogin.exe
8
+ #
9
+ # @return [String]
10
+ attr_accessor :exe_path
11
+
12
+ # Template filename of the RLogin configuration file
13
+ #
14
+ # @return [String]
15
+ attr_accessor :config_path
16
+
17
+ def initialize
18
+ @exe_path = UNSET_VALUE
19
+ @config_path = UNSET_VALUE
20
+ end
21
+
22
+ def finalize!
23
+ @exe_path = nil if @exe_path == UNSET_VALUE
24
+ @config_path = nil if @config_path == UNSET_VALUE
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ require "vagrant"
2
+
3
+ module VagrantRLogin
4
+ class Plugin < Vagrant.plugin("2")
5
+ name "RLogin Plugin"
6
+ description <<-DESC
7
+ This plugin enables to ssh into vm using RLogin.
8
+ DESC
9
+
10
+ command "rlogin" do
11
+ require_relative "command"
12
+ Command
13
+ end
14
+
15
+ config "rlogin" do
16
+ require_relative "config"
17
+ Config
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module VagrantRLogin
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-rlogin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-rlogin"
8
+ spec.version = VagrantRLogin::VERSION
9
+ spec.authors = ["Toshiyuki Goto"]
10
+ spec.email = ["ngyuki.jp@gmail.com"]
11
+ spec.summary = "This plugin enables to ssh into vm using RLogin."
12
+ spec.description = "This plugin enables to ssh into vm using RLogin."
13
+ spec.homepage = "https://github.com/ngyuki"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-rlogin
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Toshiyuki Goto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: This plugin enables to ssh into vm using RLogin.
42
+ email:
43
+ - ngyuki.jp@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/vagrant-rlogin.rb
54
+ - lib/vagrant-rlogin/command.rb
55
+ - lib/vagrant-rlogin/config.rb
56
+ - lib/vagrant-rlogin/plugin.rb
57
+ - lib/vagrant-rlogin/version.rb
58
+ - vagrant-rlogin.gemspec
59
+ homepage: https://github.com/ngyuki
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.4.5.1
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: This plugin enables to ssh into vm using RLogin.
83
+ test_files: []