vagrant-lxss-plugin 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee38d5c2fb47a3656e3cee7398839e337f5010f4
4
+ data.tar.gz: 57cdcb81eaebf34f449a56c8b315d99d1a5db5a8
5
+ SHA512:
6
+ metadata.gz: 007e5eff95831526c0edebb52575dba447d7965719c837f2b57a9d4ea14019d6f1529dd15820b8433c118a76fe6b9331a3c6b00001a74c92c9ad5fa804984ee3
7
+ data.tar.gz: 3a98aa80133cf5558776f2dfb966c8fef865e95b9ff5ef6e6c47f8a59b47a37e0f2a064fb426444e53385168ddc69a0556e8a0e3ff1e2f0220ec017f872a2099
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ Gemfile.lock
11
+ .tags*
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
5
+ end
6
+
7
+ group :plugins do
8
+ gem "vagrant-lxss-plugin", path: "."
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2016 Connor Spencer Harries
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ vagrant-lxss-plugin
2
+ ===================
3
+
4
+ Simple plugin to enable you to SSH into Vagrant machines using Bash on Ubuntu on Windows.
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ $stdout.sync = true
5
+ $stderr.sync = true
6
+
7
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,3 @@
1
+ require 'vagrant-lxss-plugin/command'
2
+ require 'vagrant-lxss-plugin/plugin'
3
+ require 'vagrant-lxss-plugin/version'
@@ -0,0 +1,84 @@
1
+ require 'optparse'
2
+
3
+ module VagrantLxss
4
+ class Command < Vagrant.plugin(2, :command)
5
+ def self.synopsis
6
+ "connects to a machine using Bash on Ubuntu on Windows"
7
+ end
8
+
9
+ def execute
10
+ raise Vagrant::Errors::CapabilityHostNotDetected unless is_win_x?
11
+ raise Vagrant::Errors::CapabilityNotFound unless is_bash_installed?
12
+
13
+ options = {
14
+ :help => false
15
+ }
16
+
17
+ opts = OptionParser.new do |o|
18
+ o.banner = "Usage: vagrant bash [name|id]"
19
+ o.separator ""
20
+
21
+ o.on("-h", "--help", "Display command help") do |h|
22
+ options[:help] = h
23
+ end
24
+ end
25
+
26
+ argv = parse_options(opts)
27
+ return -1 if !argv
28
+
29
+ if options[:help]
30
+ @logger.info('Connect to a machine using the Bash shell provided by \'Ubuntu on Windows\'')
31
+ return 0
32
+ end
33
+
34
+ with_target_vms(argv) do |machine|
35
+ ssh_info = machine.ssh_info
36
+ raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
37
+
38
+ ssh_options = ["#{ssh_info[:username]}@#{ssh_info[:host]}"]
39
+ ssh_options += ["-p #{ssh_info[:port]}"] if ssh_info[:port] != 22
40
+ ssh_options += ["-A"] if ssh_info[:forward_agent]
41
+ ssh_options += ["-v"]
42
+
43
+ key_file = nil
44
+ dir = nil
45
+ if ssh_info[:private_key_path].any?
46
+ ssh_info[:private_key_path].each { |path|
47
+ if File.exists? path
48
+ key_file = File.basename(path)
49
+ dir = File.dirname(path)
50
+ break
51
+ end
52
+ }
53
+ end
54
+
55
+ unless dir.nil? and dir.casecmp(Dir.pwd).zero?
56
+ Dir.chdir(dir)
57
+ ssh_options += [ "-i #{key_file}" ]
58
+ end
59
+
60
+ command = "C:\\Windows\\system32\\bash.exe -c 'ssh #{ssh_options.join(' ')}'"
61
+ @logger.info("Full command: #{command}")
62
+ output = system(command)
63
+ @logger.info("Output: #{output}")
64
+ return 0
65
+ end
66
+ end
67
+
68
+ def is_bash_installed?
69
+ system("C:\\Windows\\system32\\bash.exe -c 'echo \"hello\"'")
70
+ end
71
+
72
+ def is_win_x?
73
+ false unless Gem.win_platform?
74
+ result = `cmd /C ver`
75
+ return result =~ /\[Version 10.*\]/
76
+ end
77
+
78
+ def convert_path (path)
79
+ path = path.gsub '\\', '/'
80
+ path = path.gsub (/^([A-Z])\:\//i) { '/mnt/' << $1.downcase << '/' }
81
+ return path
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,13 @@
1
+ require 'vagrant'
2
+
3
+ module VagrantLxss
4
+ class Plugin < Vagrant.plugin(2)
5
+ name "vagrant-lxss-plugin"
6
+ description "vagrant-lxss-plugin allows you to ssh into your virtual machines using Bash on Ubuntu on Windows 10"
7
+
8
+ command "bash" do
9
+ require File.expand_path("../command", __FILE__)
10
+ Command
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module VagrantLxss
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-lxss-plugin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-lxss-plugin"
8
+ spec.version = VagrantLxss::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ["Connor Spencer Harries"]
11
+ spec.email = ["connorsharries96@gmail.com"]
12
+ spec.license = "MIT"
13
+ spec.homepage = "https://github.com/csh/vagrant-lxss-plugin"
14
+ spec.summary = "Vagrant plugin to allow VM ssh using Bash on Ubuntu on Windows"
15
+ spec.description = "Vagrant plugin to allow VM ssh using Bash on Ubuntu on Windows"
16
+
17
+ spec.required_ruby_version = ">= 2.1.0"
18
+ spec.required_rubygems_version = ">= 1.4.0"
19
+
20
+ spec.files = `git ls-files`.split("\n")
21
+ spec.require_path = 'lib'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.13"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-lxss-plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Connor Spencer Harries
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-01 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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: Vagrant plugin to allow VM ssh using Bash on Ubuntu on Windows
42
+ email:
43
+ - connorsharries96@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.MD
52
+ - Rakefile
53
+ - lib/vagrant-lxss-plugin.rb
54
+ - lib/vagrant-lxss-plugin/command.rb
55
+ - lib/vagrant-lxss-plugin/plugin.rb
56
+ - lib/vagrant-lxss-plugin/version.rb
57
+ - vagrant-lxss-plugin.gemspec
58
+ homepage: https://github.com/csh/vagrant-lxss-plugin
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.1.0
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.4.0
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.8
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Vagrant plugin to allow VM ssh using Bash on Ubuntu on Windows
82
+ test_files: []