vagrant-poderosa 0.1.0

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: 8b95f3c54030c035f0b1dbebf0cb416d30d0d3ee
4
+ data.tar.gz: e1c4a71e6b023bce2c990b2f5f089e5d6b9ea9e3
5
+ SHA512:
6
+ metadata.gz: f215c2ced4d7c810ad5ef991ed64c5014aeae9df03ddb1e5152930603ee5b47a2c1bc5fb40d4ea3bb1d689e551a29251f3f1b7e5d0e363e2023a0fe36d885105
7
+ data.tar.gz: b6f072872dfc899ac2edb68544b0d00c5959c048d4aa6fe483c37395f8ef6309552dd40f236c0f9dd966a1916d1549f7149db751cf42ab8d8ad12a5b6ab748e4
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ /.bundle
2
+ /pkg/
3
+ Vagrantfile
4
+ /.vagrant/
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-poderosa', path: '.'
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,110 @@
1
+ GIT
2
+ remote: https://github.com/mitchellh/vagrant.git
3
+ revision: 038276fd49a8d7356311f7ee47412fae46884500
4
+ specs:
5
+ vagrant (1.8.0.dev)
6
+ bundler (>= 1.5.2, <= 1.10.6)
7
+ childprocess (~> 0.5.0)
8
+ erubis (~> 2.7.0)
9
+ hashicorp-checkpoint (~> 0.1.1)
10
+ i18n (>= 0.6.0, <= 0.8.0)
11
+ listen (~> 3.0.2)
12
+ log4r (~> 1.1.9, < 1.1.11)
13
+ net-scp (~> 1.1.0)
14
+ net-sftp (~> 2.1)
15
+ net-ssh (~> 3.0.1)
16
+ nokogiri (= 1.6.3.1)
17
+ rb-kqueue (~> 0.2.0)
18
+ rest-client (>= 1.6.0, < 2.0)
19
+ wdm (~> 0.1.0)
20
+ winrm (~> 1.3)
21
+ winrm-fs (~> 0.2.2)
22
+
23
+ PATH
24
+ remote: .
25
+ specs:
26
+ vagrant-poderosa (0.1.0)
27
+
28
+ GEM
29
+ remote: https://rubygems.org/
30
+ specs:
31
+ builder (3.2.2)
32
+ childprocess (0.5.8)
33
+ ffi (~> 1.0, >= 1.0.11)
34
+ domain_name (0.5.25)
35
+ unf (>= 0.0.5, < 1.0.0)
36
+ erubis (2.7.0)
37
+ ffi (1.9.10-x64-mingw32)
38
+ gssapi (1.2.0)
39
+ ffi (>= 1.0.1)
40
+ gyoku (1.3.1)
41
+ builder (>= 2.1.2)
42
+ hashicorp-checkpoint (0.1.4)
43
+ http-cookie (1.0.2)
44
+ domain_name (~> 0.5)
45
+ httpclient (2.7.0.1)
46
+ i18n (0.7.0)
47
+ listen (3.0.5)
48
+ rb-fsevent (>= 0.9.3)
49
+ rb-inotify (>= 0.9)
50
+ little-plugger (1.1.4)
51
+ log4r (1.1.10)
52
+ logging (1.8.2)
53
+ little-plugger (>= 1.1.3)
54
+ multi_json (>= 1.8.4)
55
+ mime-types (2.99)
56
+ mini_portile (0.6.0)
57
+ multi_json (1.11.2)
58
+ net-scp (1.1.2)
59
+ net-ssh (>= 2.6.5)
60
+ net-sftp (2.1.2)
61
+ net-ssh (>= 2.6.5)
62
+ net-ssh (3.0.1)
63
+ netrc (0.11.0)
64
+ nokogiri (1.6.3.1-x64-mingw32)
65
+ mini_portile (= 0.6.0)
66
+ nori (2.6.0)
67
+ rake (10.4.2)
68
+ rb-fsevent (0.9.6)
69
+ rb-inotify (0.9.5)
70
+ ffi (>= 0.5.0)
71
+ rb-kqueue (0.2.4)
72
+ ffi (>= 0.5.0)
73
+ rest-client (1.8.0-x64-mingw32)
74
+ ffi (~> 1.9)
75
+ http-cookie (>= 1.0.2, < 2.0)
76
+ mime-types (>= 1.16, < 3.0)
77
+ netrc (~> 0.7)
78
+ rubyntlm (0.4.0)
79
+ rubyzip (1.1.7)
80
+ unf (0.1.4)
81
+ unf_ext
82
+ unf_ext (0.0.7.1-x64-mingw32)
83
+ uuidtools (2.1.5)
84
+ wdm (0.1.1)
85
+ winrm (1.3.6)
86
+ builder (>= 2.1.2)
87
+ gssapi (~> 1.2)
88
+ gyoku (~> 1.0)
89
+ httpclient (~> 2.2, >= 2.2.0.2)
90
+ logging (>= 1.6.1, < 3.0)
91
+ nori (~> 2.0)
92
+ rubyntlm (~> 0.4.0)
93
+ uuidtools (~> 2.1.2)
94
+ winrm-fs (0.2.3)
95
+ erubis (~> 2.7)
96
+ logging (~> 1.6, >= 1.6.1)
97
+ rubyzip (~> 1.1)
98
+ winrm (~> 1.3.0)
99
+
100
+ PLATFORMS
101
+ x64-mingw32
102
+
103
+ DEPENDENCIES
104
+ bundler (~> 1.7)
105
+ rake (~> 10.0)
106
+ vagrant!
107
+ vagrant-poderosa!
108
+
109
+ BUNDLED WITH
110
+ 1.10.5
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 IIBUN Toshiyuki
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,43 @@
1
+ # Vagrant Poderosa Plugin
2
+
3
+ This is a Vagrant plugin that enables to ssh into vm with Poderosa.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ vagrant plugin install vagrant-poderosa
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ vagrant poderosa [vm-name]
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ ```ruby
20
+ Vagrant.configure(2) do |config|
21
+ # ...
22
+ config.poderosa.exe_path = '[path to poderosa]/poderosa.exe'
23
+ # ...
24
+ end
25
+ ```
26
+
27
+ * ```exe_path``` A poderosa.exe file path. We will find real path
28
+ * If set and executable, use it.
29
+ * If set and not executable, search in PATH.
30
+ * If not set, search "poderosa.exe" in PATH.
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/tiibun/vagrant-poderosa/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
39
+
40
+ ## Thanks
41
+
42
+ Vagrant ( https://github.com/https://github.com/mitchellh/vagrant )
43
+ vagrant-multi-putty ( https://github.com/nickryand/vagrant-multi-putty )
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,72 @@
1
+ require 'optparse'
2
+ require 'pathname'
3
+
4
+ module VagrantPoderosa
5
+ #
6
+ class Command < Vagrant.plugin(2, :command)
7
+ def self.synopsis
8
+ 'connects to machine via SSH using Poderosa'
9
+ end
10
+
11
+ def execute
12
+ opts = OptionParser.new do |opt|
13
+ opt.banner = 'Usage: vagrant poderosa [vm-name...]'
14
+
15
+ opt.separator ''
16
+ end
17
+
18
+ argv = parse_options(opts)
19
+ return -1 unless argv
20
+
21
+ with_target_vms(argv, single_target: true) do |vm|
22
+ @config = vm.config.poderosa
23
+
24
+ ssh_info = vm.ssh_info
25
+ @logger.debug("ssh_info is #{ssh_info}")
26
+ # If ssh_info is nil, the machine is not ready for ssh.
27
+ fail Vagrant::Errors::SSHNotReady if ssh_info.nil?
28
+
29
+ exe_path = find_exe_path(@config.exe_path)
30
+ return -1 unless exe_path
31
+
32
+ commands = [
33
+ "\"#{exe_path}\"",
34
+ '-open',
35
+ create_shortcut(vm, ssh_info)
36
+ ]
37
+ do_process(commands)
38
+ end
39
+ end
40
+
41
+ def find_exe_path(path)
42
+ if !path.nil?
43
+ return path if File.executable?(path)
44
+
45
+ # search in PATH
46
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |p|
47
+ exe_path = Pathname(p) + path
48
+ return exe_path.to_s if exe_path.executable?
49
+ end
50
+ else
51
+ # search in PATH
52
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |p|
53
+ exe_path = Pathname(p) + 'Poderosa.exe'
54
+ return exe_path.to_s if exe_path.executable?
55
+ end
56
+ end
57
+
58
+ @env.ui.error("File is not found or executable. => #{path}")
59
+ nil
60
+ end
61
+
62
+ def create_shortcut(vm, ssh_info)
63
+ require_relative 'shortcut'
64
+ Shortcut.create_shortcut(vm, ssh_info)
65
+ end
66
+
67
+ def do_process(commands)
68
+ pid = spawn(commands.join(' '))
69
+ Process.detach(pid)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,18 @@
1
+ module VagrantPoderosa
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
+ # poderosa.exe
6
+ #
7
+ # @return [String]
8
+ attr_accessor :exe_path
9
+
10
+ def initialize
11
+ @exe_path = UNSET_VALUE
12
+ end
13
+
14
+ def finalize!
15
+ @exe_path = nil if @exe_path == UNSET_VALUE
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPoderosa
4
+ class Plugin < Vagrant.plugin("2")
5
+ name "Poderosa Plugin"
6
+ description <<-DESC
7
+ This plugin enables to ssh into vm using Poderosa.
8
+ DESC
9
+
10
+ command "poderosa" do
11
+ require_relative "command"
12
+ Command
13
+ end
14
+
15
+ config "poderosa" do
16
+ require_relative "config"
17
+ Config
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,47 @@
1
+ require 'pathname'
2
+ require 'rexml/document'
3
+ require 'tmpdir'
4
+
5
+ module VagrantPoderosa
6
+ #
7
+ class Shortcut
8
+ def self.create_shortcut(vm, ssh_info)
9
+ ssh_login_parameters = {
10
+ 'destination' => ssh_info[:host],
11
+ 'port' => ssh_info[:port],
12
+ 'account' => ssh_info[:username]
13
+ }
14
+ if ssh_info.include?(:password)
15
+ ssh_login_parameters['authentication'] = 'Password'
16
+ ssh_login_parameters['passphrase'] = ssh_info[:password]
17
+ elsif ssh_info.include?(:private_key_path)
18
+ ssh_login_parameters['authentication'] = 'PublicKey'
19
+ # FIXME: multiple identity files
20
+ ssh_login_parameters['identityFileName'] =
21
+ absolute_winpath(ssh_info[:private_key_path][0], vm.env.root_path)
22
+ end
23
+
24
+ doc = REXML::Document.new
25
+ doc << REXML::XMLDecl.new('1.0', 'UTF-8')
26
+ root = doc.add_element('poderosa-shortcut', 'version' => '4.0')
27
+ root.add_element('Poderosa.Terminal.TerminalSettings',
28
+ 'encoding' => 'UTF8', 'caption' => ssh_info[:host])
29
+ root.add_element('Poderosa.Protocols.SSHLoginParameter',
30
+ ssh_login_parameters)
31
+ # filename = Pathname(Dir.tmpdir) + (vm.name.to_s + '.gts')
32
+ # file = File.open(filename, 'wb')
33
+ Tempfile.open(vm.name.to_s + '.gts') do |file|
34
+ doc.write file
35
+ file.close
36
+ # filename
37
+ file.path
38
+ end
39
+ end
40
+
41
+ def self.absolute_winpath(path, root_path)
42
+ p = Pathname(path)
43
+ return path.gsub(%r{\/}, '\\') if p.absolute?
44
+ Pathname(root_path).join(p).to_s.gsub(%r{\/}, '\\')
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module VagrantPoderosa
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "vagrant-poderosa/version"
2
+ require "vagrant-poderosa/plugin"
3
+
4
+ module VagrantPoderosa
5
+
6
+ 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-poderosa/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-poderosa"
8
+ spec.version = VagrantPoderosa::VERSION
9
+ spec.authors = ["IIBUN Toshiyuki"]
10
+ spec.email = ["toshiyuki.iibun@gmail.com"]
11
+ spec.summary = "This plugin enables to ssh into vm using Poderosa."
12
+ spec.description = "This plugin enables to ssh into vm using Poderosa."
13
+ spec.homepage = ""
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,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-poderosa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - IIBUN Toshiyuki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-13 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 Poderosa.
42
+ email:
43
+ - toshiyuki.iibun@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - lib/vagrant-poderosa.rb
55
+ - lib/vagrant-poderosa/command.rb
56
+ - lib/vagrant-poderosa/config.rb
57
+ - lib/vagrant-poderosa/plugin.rb
58
+ - lib/vagrant-poderosa/shortcut.rb
59
+ - lib/vagrant-poderosa/version.rb
60
+ - vagrant-poderosa.gemspec
61
+ homepage: ''
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.7
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: This plugin enables to ssh into vm using Poderosa.
85
+ test_files: []