vagrant-guest-msys2 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/lib/vagrant-guest-msys2.rb +14 -0
- data/lib/vagrant-guest-msys2/cap/change_host_name.rb +39 -0
- data/lib/vagrant-guest-msys2/cap/choose_addressable_ip_addr.rb +20 -0
- data/lib/vagrant-guest-msys2/cap/configure_networks.rb +23 -0
- data/lib/vagrant-guest-msys2/cap/insert_public_key.rb +31 -0
- data/lib/vagrant-guest-msys2/cap/powershell.rb +59 -0
- data/lib/vagrant-guest-msys2/cap/reboot.rb +21 -0
- data/lib/vagrant-guest-msys2/cap/remove_public_key.rb +24 -0
- data/lib/vagrant-guest-msys2/cap/rsync.rb +2 -2
- data/lib/vagrant-guest-msys2/errors.rb +23 -0
- data/lib/vagrant-guest-msys2/guest_network.rb +127 -0
- data/lib/vagrant-guest-msys2/plugin.rb +50 -4
- data/lib/vagrant-guest-msys2/util/cap_helpers.rb +16 -0
- data/lib/vagrant-guest-msys2/version.rb +1 -1
- data/locales/en.yml +17 -0
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 026ae197e2fb6b998bdff1de9b11cd6fab7e1354
|
4
|
+
data.tar.gz: 4873e8ea80587ca21f15bc21b35ad1b06c09244d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 575ef68704c07d8726338c6ac1dd5fef45660eaba36778aa484966aa65ad138b4b7506e31caac62e290c16c42dba99a768dc3395d2fa03d33c648527cd0ef65b
|
7
|
+
data.tar.gz: e25db1a2b8cdcd48767f56036535ad54436ed41c789dc3fe92baa400269ac605ea6d730520439bb3d4094c865e6ff9382e1a3da19b7e25523ed49d9e272901f8
|
data/lib/vagrant-guest-msys2.rb
CHANGED
@@ -1 +1,15 @@
|
|
1
1
|
require "vagrant-guest-msys2/plugin"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestMSYS2
|
5
|
+
lib_path = Pathname.new(File.expand_path('../vagrant-guest-msys2', __FILE__))
|
6
|
+
autoload :Errors, lib_path.join('errors')
|
7
|
+
|
8
|
+
# This returns the path to the source of this plugin.
|
9
|
+
#
|
10
|
+
# @return [Pathname]
|
11
|
+
def self.source_root
|
12
|
+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "vagrant-guest-msys2/util/cap_helpers"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestMSYS2
|
5
|
+
module Cap
|
6
|
+
module ChangeHostName
|
7
|
+
def self.change_host_name(machine, name)
|
8
|
+
change_host_name_and_wait(machine, name, machine.config.vm.graceful_halt_timeout)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.change_host_name_and_wait(machine, name, sleep_timeout)
|
12
|
+
machine.guest.capability(:powershell_check) if machine.guest.capability?(:powershell_check)
|
13
|
+
|
14
|
+
escaped_name = name.gsub("'", "''")
|
15
|
+
|
16
|
+
# If the configured name matches the current name, then bail
|
17
|
+
# We cannot use %ComputerName% because it truncates at 15 chars
|
18
|
+
return if machine.communicate.test(Util::CapHelpers.wrap_powershell("if ([System.Net.Dns]::GetHostName() -eq '#{escaped_name}') { exit 0 } exit 1"))
|
19
|
+
|
20
|
+
# Rename and reboot host if rename succeeded
|
21
|
+
script = <<-EOH.gsub(/^ {14}/, '')
|
22
|
+
$computer = Get-WmiObject -Class Win32_ComputerSystem
|
23
|
+
$retval = $computer.rename('#{escaped_name}').returnvalue
|
24
|
+
if ($retval -eq 0) {
|
25
|
+
shutdown -r -t 5 -f -d p:4:1 -c "Vagrant Rename Computer"
|
26
|
+
}
|
27
|
+
exit $retval
|
28
|
+
EOH
|
29
|
+
machine.ui.info I18n.t("vagrant-guest-msys2.info.run_change_host_name", host: name)
|
30
|
+
machine.communicate.execute(Util::CapHelpers.wrap_powershell(script))
|
31
|
+
|
32
|
+
# Don't continue until the machine has shutdown and rebooted
|
33
|
+
machine.ui.info I18n.t("vagrant-guest-msys2.info.run_wait_for_reboot", host: name)
|
34
|
+
sleep(sleep_timeout)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestMSYS2
|
3
|
+
module Cap
|
4
|
+
module ChooseAddressableIPAddr
|
5
|
+
def self.choose_addressable_ip_addr(machine, possible)
|
6
|
+
machine.communicate.tap do |comm|
|
7
|
+
possible.each do |ip|
|
8
|
+
command = "ping -n 1 -w 1 #{ip}"
|
9
|
+
if comm.test(command)
|
10
|
+
return ip
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require_relative "../guest_network"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module GuestMSYS2
|
6
|
+
module Cap
|
7
|
+
module ConfigureNetworks
|
8
|
+
@@logger = Log4r::Logger.new("vagrant::guest::windows::configure_networks")
|
9
|
+
|
10
|
+
def self.configure_networks(machine, networks)
|
11
|
+
@@logger.debug("Networks: #{networks.inspect}")
|
12
|
+
@@logger.debug("communicator: #{machine.config.vm.communicator.inspect}")
|
13
|
+
|
14
|
+
guest_network = GuestNetwork.new(machine.communicate)
|
15
|
+
network_adapters = guest_network.network_adapters()
|
16
|
+
@@logger.debug("network_adapters: #{network_adapters}")
|
17
|
+
|
18
|
+
return
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestMSYS2
|
3
|
+
module Cap
|
4
|
+
class InsertPublicKey
|
5
|
+
def self.insert_public_key(machine, contents)
|
6
|
+
comm = machine.communicate
|
7
|
+
contents = contents.chomp
|
8
|
+
|
9
|
+
remote_path = "/tmp/vagrant-authorized-keys-#{Time.now.to_i}"
|
10
|
+
Tempfile.open("vagrant-msys2-insert-public-key") do |f|
|
11
|
+
f.binmode
|
12
|
+
f.write(contents)
|
13
|
+
f.fsync
|
14
|
+
f.close
|
15
|
+
comm.upload(f.path, remote_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
comm.execute <<-EOH.gsub(/^ {12}/, '')
|
19
|
+
mkdir -p ~/.ssh
|
20
|
+
chmod 0700 ~/.ssh
|
21
|
+
cat '#{remote_path}' >> ~/.ssh/authorized_keys
|
22
|
+
chmod 0600 ~/.ssh/authorized_keys
|
23
|
+
|
24
|
+
# Remove the temporary file
|
25
|
+
rm -f '#{remote_path}'
|
26
|
+
EOH
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestMSYS2
|
3
|
+
module Cap
|
4
|
+
class Powershell
|
5
|
+
def self.powershell_installed(machine)
|
6
|
+
machine.communicate.test('which powershell')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.powershell_install(machine)
|
10
|
+
machine.ui.info I18n.t("vagrant-guest-msys2.info.run_powershell_install")
|
11
|
+
script = <<-EOH.gsub(/^ {12}/, '')
|
12
|
+
set -e
|
13
|
+
OS_VERSION=`echo '' | wmic os get version | grep -o '^[0-9]*\\.[0-9]*'`
|
14
|
+
OS_ARCH=`regtool -l get '\\HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\PROCESSOR_ARCHITECTURE' | tr '[:upper:]' '[:lower:]'`
|
15
|
+
|
16
|
+
if [ "$OS_VERSION" = "5.1" -a "$OS_ARCH" = "x86" ]; then # Windows XP 32-bit
|
17
|
+
pacman -S --noconfirm wget
|
18
|
+
|
19
|
+
if ! (regtool -l get '\\HKLM\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727\\SP' | grep -q "1"); then
|
20
|
+
wget --no-verbose --no-check-certificate "https://download.microsoft.com/download/0/8/c/08c19fa4-4c4f-4ffb-9d6c-150906578c9e/NetFx20SP1_x86.exe" -O "/tmp/NetFx20SP1_x86.exe"
|
21
|
+
/tmp/NetFx20SP1_x86.exe //passive //norestart
|
22
|
+
rm /tmp/NetFx20SP1_x86.exe
|
23
|
+
fi
|
24
|
+
|
25
|
+
if ! (regtool -l get '\\HKLM\\SOFTWARE\\Microsoft\\PowerShell\\1\\PowerShellEngine\\PowerShellVersion' | grep -q "2\\.0"); then
|
26
|
+
wget --no-verbose --no-check-certificate "https://download.microsoft.com/download/E/C/E/ECE99583-2003-455D-B681-68DB610B44A4/WindowsXP-KB968930-x86-ENG.exe" -O "/tmp/WindowsXP-KB968930-x86-ENG.exe"
|
27
|
+
/tmp/WindowsXP-KB968930-x86-ENG.exe //passive //norestart
|
28
|
+
rm /tmp/WindowsXP-KB968930-x86-ENG.exe
|
29
|
+
fi
|
30
|
+
else
|
31
|
+
(>&2 echo Unsupported OS $OS_VERSION $OS_ARCH)
|
32
|
+
fi
|
33
|
+
|
34
|
+
if [ -f "c:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -a ! -f /bin/powershell ]; then
|
35
|
+
echo '#!/bin/sh'$'\\n''"c:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -inputformat none $@' > /bin/powershell
|
36
|
+
chmod 755 /bin/powershell
|
37
|
+
fi
|
38
|
+
|
39
|
+
which powershell
|
40
|
+
EOH
|
41
|
+
machine.communicate.execute(script)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.powershell_check(machine)
|
45
|
+
if machine.guest.capability?(:powershell_installed)
|
46
|
+
installed = machine.guest.capability(:powershell_installed)
|
47
|
+
if !installed
|
48
|
+
if machine.guest.capability?(:powershell_install)
|
49
|
+
machine.guest.capability(:powershell_install)
|
50
|
+
end
|
51
|
+
installed = machine.guest.capability(:powershell_installed)
|
52
|
+
raise Errors::PowershellNotInstalledInGuest if !installed
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestWindows
|
3
|
+
module Cap
|
4
|
+
class Reboot
|
5
|
+
def self.wait_for_reboot(machine)
|
6
|
+
return if machine.config.vm.communicator != :ssh
|
7
|
+
|
8
|
+
script = File.expand_path("../../scripts/reboot_detect.ps1", __FILE__)
|
9
|
+
script = File.read(script)
|
10
|
+
while machine.communicate.execute(script, error_check: false) != 0
|
11
|
+
sleep 10
|
12
|
+
end
|
13
|
+
|
14
|
+
# This re-establishes our symbolic links if they were
|
15
|
+
# created between now and a reboot
|
16
|
+
machine.communicate.execute("net use", error_check: false)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "vagrant/util/shell_quote"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestMSYS2
|
5
|
+
module Cap
|
6
|
+
class RemovePublicKey
|
7
|
+
def self.remove_public_key(machine, contents)
|
8
|
+
contents = contents.chomp
|
9
|
+
contents = Vagrant::Util::ShellQuote.escape(contents, "'")
|
10
|
+
|
11
|
+
machine.communicate.tap do |comm|
|
12
|
+
if comm.test("test -f ~/.ssh/authorized_keys")
|
13
|
+
comm.execute(<<SCRIPT)
|
14
|
+
sed -e '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.new
|
15
|
+
mv ~/.ssh/authorized_keys.new ~/.ssh/authorized_keys
|
16
|
+
chmod 600 ~/.ssh/authorized_keys
|
17
|
+
SCRIPT
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -3,7 +3,7 @@ module VagrantPlugins
|
|
3
3
|
module Cap
|
4
4
|
class RSync
|
5
5
|
def self.rsync_installed(machine)
|
6
|
-
machine.communicate.test(
|
6
|
+
machine.communicate.test('which rsync')
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.rsync_install(machine)
|
@@ -12,7 +12,7 @@ module VagrantPlugins
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.rsync_command(machine)
|
15
|
-
|
15
|
+
'rsync'
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.rsync_pre(machine, opts)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestMSYS2
|
3
|
+
module Errors
|
4
|
+
# A convenient superclass for all our errors.
|
5
|
+
class MSYS2Error < Vagrant::Errors::VagrantError
|
6
|
+
error_namespace("vagrant-guest-msys2.errors")
|
7
|
+
end
|
8
|
+
|
9
|
+
class RenameComputerFailed < MSYS2Error
|
10
|
+
error_key(:rename_computer_failed)
|
11
|
+
end
|
12
|
+
|
13
|
+
class PowershellNotInstalledInGuest < MSYS2Error
|
14
|
+
error_key(:powershell_not_installed_in_guest)
|
15
|
+
end
|
16
|
+
|
17
|
+
class PowershellInstallationFailed < MSYS2Error
|
18
|
+
error_key(:powershell_installation_failed)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestMSYS2
|
5
|
+
# Manages the remote Windows guest network.
|
6
|
+
class GuestNetwork
|
7
|
+
PS_GET_WSMAN_VER = '((test-wsman).productversion.split(" ") | select -last 1).split("\.")[0]'
|
8
|
+
WQL_NET_ADAPTERS_V2 = 'SELECT * FROM Win32_NetworkAdapter WHERE MACAddress IS NOT NULL'
|
9
|
+
|
10
|
+
def initialize(communicator)
|
11
|
+
@logger = Log4r::Logger.new("vagrant::windows::guestnetwork")
|
12
|
+
@communicator = communicator
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns an array of all NICs on the guest. Each array entry is a
|
16
|
+
# Hash of the NICs properties.
|
17
|
+
#
|
18
|
+
# @return [Array]
|
19
|
+
def network_adapters
|
20
|
+
@logger.debug("querying network adapters")
|
21
|
+
|
22
|
+
wsman_version == 2? network_adapters_v2_winrm : network_adapters_v3_winrm
|
23
|
+
end
|
24
|
+
|
25
|
+
# Checks to see if the specified NIC is currently configured for DHCP.
|
26
|
+
#
|
27
|
+
# @return [Boolean]
|
28
|
+
def is_dhcp_enabled(nic_index)
|
29
|
+
cmd = <<-EOH
|
30
|
+
if (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=#{nic_index} and DHCPEnabled=True") {
|
31
|
+
exit 0
|
32
|
+
}
|
33
|
+
exit 1
|
34
|
+
EOH
|
35
|
+
@communicator.test(cmd)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Configures the specified interface for DHCP
|
39
|
+
#
|
40
|
+
# @param [Integer] The interface index.
|
41
|
+
# @param [String] The unique name of the NIC, such as 'Local Area Connection'.
|
42
|
+
def configure_dhcp_interface(nic_index, net_connection_id)
|
43
|
+
@logger.info("Configuring NIC #{net_connection_id} for DHCP")
|
44
|
+
if !is_dhcp_enabled(nic_index)
|
45
|
+
netsh = "netsh interface ip set address \"#{net_connection_id}\" dhcp"
|
46
|
+
@communicator.execute(netsh)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Configures the specified interface using a static address
|
51
|
+
#
|
52
|
+
# @param [Integer] The interface index.
|
53
|
+
# @param [String] The unique name of the NIC, such as 'Local Area Connection'.
|
54
|
+
# @param [String] The static IP address to assign to the specified NIC.
|
55
|
+
# @param [String] The network mask to use with the static IP.
|
56
|
+
def configure_static_interface(nic_index, net_connection_id, ip, netmask)
|
57
|
+
@logger.info("Configuring NIC #{net_connection_id} using static ip #{ip}")
|
58
|
+
#netsh interface ip set address "Local Area Connection 2" static 192.168.33.10 255.255.255.0
|
59
|
+
netsh = "netsh interface ip set address \"#{net_connection_id}\" static #{ip} #{netmask}"
|
60
|
+
@communicator.execute(netsh)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Sets all networks on the guest to 'Work Network' mode. This is
|
64
|
+
# to allow guest access from the host via a private IP on Win7
|
65
|
+
# https://github.com/WinRb/vagrant-windows/issues/63
|
66
|
+
def set_all_networks_to_work
|
67
|
+
@logger.info("Setting all networks to 'Work Network'")
|
68
|
+
command = File.read(File.expand_path("../scripts/set_work_network.ps1", __FILE__))
|
69
|
+
@communicator.execute(command)
|
70
|
+
end
|
71
|
+
|
72
|
+
protected
|
73
|
+
|
74
|
+
# Checks the WinRS version on the guest. Usually 2 on Windows 7/2008
|
75
|
+
# and 3 on Windows 8/2012.
|
76
|
+
#
|
77
|
+
# @return [Integer]
|
78
|
+
def wsman_version
|
79
|
+
@logger.debug("querying WSMan version")
|
80
|
+
version = ''
|
81
|
+
@communicator.execute(PS_GET_WSMAN_VER) do |type, line|
|
82
|
+
version = version + "#{line}" if type == :stdout && !line.nil?
|
83
|
+
end
|
84
|
+
@logger.debug("wsman version: #{version}")
|
85
|
+
Integer(version)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns an array of all NICs on the guest. Each array entry is a
|
89
|
+
# Hash of the NICs properties. This method should only be used on
|
90
|
+
# guests that have WinRS version 2.
|
91
|
+
#
|
92
|
+
# @return [Array]
|
93
|
+
def network_adapters_v2_winrm
|
94
|
+
@logger.debug("querying network adapters")
|
95
|
+
|
96
|
+
# Get all NICs that have a MAC address
|
97
|
+
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
|
98
|
+
adapters = @communicator.execute(WQL_NET_ADAPTERS_V2, { shell: :wql } )[:win32_network_adapter]
|
99
|
+
@logger.debug("#{adapters.inspect}")
|
100
|
+
return adapters
|
101
|
+
end
|
102
|
+
|
103
|
+
# Returns an array of all NICs on the guest. Each array entry is a
|
104
|
+
# Hash of the NICs properties. This method should only be used on
|
105
|
+
# guests that have WinRS version 3.
|
106
|
+
#
|
107
|
+
# This method is a workaround until the WinRM gem supports WinRS version 3.
|
108
|
+
#
|
109
|
+
# @return [Array]
|
110
|
+
def network_adapters_v3_winrm
|
111
|
+
command = File.read(File.expand_path("../scripts/winrs_v3_get_adapters.ps1", __FILE__))
|
112
|
+
output = ""
|
113
|
+
@communicator.execute(command) do |type, line|
|
114
|
+
output = output + "#{line}" if type == :stdout && !line.nil?
|
115
|
+
end
|
116
|
+
|
117
|
+
adapters = []
|
118
|
+
JSON.parse(output).each do |nic|
|
119
|
+
adapters << nic.inject({}){ |memo,(k,v)| memo[k.to_sym] = v; memo }
|
120
|
+
end
|
121
|
+
|
122
|
+
@logger.debug("#{adapters.inspect}")
|
123
|
+
return adapters
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -11,6 +11,8 @@ module VagrantPlugins
|
|
11
11
|
description "MSYS2 guest support."
|
12
12
|
|
13
13
|
guest('msys2') do
|
14
|
+
init!
|
15
|
+
|
14
16
|
require File.expand_path("../guest", __FILE__)
|
15
17
|
Guest
|
16
18
|
end
|
@@ -21,13 +23,13 @@ module VagrantPlugins
|
|
21
23
|
end
|
22
24
|
|
23
25
|
guest_capability("msys2", "insert_public_key") do
|
24
|
-
|
25
|
-
|
26
|
+
require_relative "cap/insert_public_key"
|
27
|
+
Cap::InsertPublicKey
|
26
28
|
end
|
27
29
|
|
28
30
|
guest_capability("msys2", "remove_public_key") do
|
29
|
-
|
30
|
-
|
31
|
+
require_relative "cap/remove_public_key"
|
32
|
+
Cap::RemovePublicKey
|
31
33
|
end
|
32
34
|
|
33
35
|
guest_capability("msys2", "rsync_installed") do
|
@@ -55,6 +57,50 @@ module VagrantPlugins
|
|
55
57
|
Cap::RSync
|
56
58
|
end
|
57
59
|
|
60
|
+
guest_capability("msys2", "choose_addressable_ip_addr") do
|
61
|
+
require_relative "cap/choose_addressable_ip_addr"
|
62
|
+
Cap::ChooseAddressableIPAddr
|
63
|
+
end
|
64
|
+
|
65
|
+
guest_capability("msys2", "change_host_name") do
|
66
|
+
require_relative "cap/change_host_name"
|
67
|
+
Cap::ChangeHostName
|
68
|
+
end
|
69
|
+
|
70
|
+
guest_capability("msys2", "wait_for_reboot") do
|
71
|
+
require_relative "cap/reboot"
|
72
|
+
Cap::Reboot
|
73
|
+
end
|
74
|
+
|
75
|
+
guest_capability("msys2", "powershell_check") do
|
76
|
+
require_relative "cap/powershell"
|
77
|
+
Cap::Powershell
|
78
|
+
end
|
79
|
+
|
80
|
+
guest_capability("msys2", "powershell_install") do
|
81
|
+
require_relative "cap/powershell"
|
82
|
+
Cap::Powershell
|
83
|
+
end
|
84
|
+
|
85
|
+
guest_capability("msys2", "powershell_installed") do
|
86
|
+
require_relative "cap/powershell"
|
87
|
+
Cap::Powershell
|
88
|
+
end
|
89
|
+
|
90
|
+
guest_capability("msys2", "configure_networks") do
|
91
|
+
require_relative "cap/configure_networks"
|
92
|
+
Cap::ConfigureNetworks
|
93
|
+
end
|
94
|
+
|
95
|
+
protected
|
96
|
+
|
97
|
+
def self.init!
|
98
|
+
return if defined?(@_init)
|
99
|
+
I18n.load_path << File.expand_path('locales/en.yml', VagrantPlugins::GuestMSYS2.source_root)
|
100
|
+
I18n.reload!
|
101
|
+
@_init = true
|
102
|
+
end
|
103
|
+
|
58
104
|
end
|
59
105
|
end
|
60
106
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestMSYS2
|
3
|
+
module Util
|
4
|
+
module CapHelpers
|
5
|
+
def self.wrap_powershell(script)
|
6
|
+
wrapped = <<-EOH.gsub(/^ {12}/, '')
|
7
|
+
cat << 'EOF' | powershell -InputFormat none -Command -
|
8
|
+
#{script}
|
9
|
+
EOF
|
10
|
+
EOH
|
11
|
+
wrapped
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
en:
|
2
|
+
vagrant-guest-msys2:
|
3
|
+
info:
|
4
|
+
run_powershell_install: "Installing powershell to the VM..."
|
5
|
+
run_change_host_name: "Changing hostname to %{host}"
|
6
|
+
run_wait_for_reboot: "Waiting until %{host} reboots"
|
7
|
+
|
8
|
+
errors:
|
9
|
+
rename_computer_failed: |-
|
10
|
+
Renaming the MSYS2 guest failed. Most often this is because you've
|
11
|
+
specified a FQDN instead of just a host name.
|
12
|
+
|
13
|
+
Ensure the new guest name is properly formatted. Standard names may
|
14
|
+
contain letters (a-z, A-Z), numbers (0-9), and hypens (-), but no
|
15
|
+
spaces or periods (.). The name may not consist entirely of digits.
|
16
|
+
|
17
|
+
powershell_not_installed_in_guest: "Powershell is not installed in this VM."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-guest-msys2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: 'Adds MSYS2 (https://sourceforge.net/p/msys2/wiki/Home/) as a guest for
|
15
15
|
Vagrant. '
|
@@ -20,9 +20,19 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- lib/vagrant-guest-msys2.rb
|
22
22
|
- lib/vagrant-guest-msys2/plugin.rb
|
23
|
+
- lib/vagrant-guest-msys2/cap/change_host_name.rb
|
24
|
+
- lib/vagrant-guest-msys2/cap/choose_addressable_ip_addr.rb
|
25
|
+
- lib/vagrant-guest-msys2/cap/powershell.rb
|
26
|
+
- lib/vagrant-guest-msys2/cap/remove_public_key.rb
|
23
27
|
- lib/vagrant-guest-msys2/cap/halt.rb
|
28
|
+
- lib/vagrant-guest-msys2/cap/configure_networks.rb
|
29
|
+
- lib/vagrant-guest-msys2/cap/reboot.rb
|
24
30
|
- lib/vagrant-guest-msys2/cap/rsync.rb
|
31
|
+
- lib/vagrant-guest-msys2/cap/insert_public_key.rb
|
32
|
+
- lib/vagrant-guest-msys2/util/cap_helpers.rb
|
33
|
+
- lib/vagrant-guest-msys2/guest_network.rb
|
25
34
|
- lib/vagrant-guest-msys2/version.rb
|
35
|
+
- lib/vagrant-guest-msys2/errors.rb
|
26
36
|
- lib/vagrant-guest-msys2/guest.rb
|
27
37
|
- Rakefile
|
28
38
|
- CHANGELOG.md
|
@@ -30,6 +40,7 @@ files:
|
|
30
40
|
- Gemfile
|
31
41
|
- README.md
|
32
42
|
- LICENSE
|
43
|
+
- locales/en.yml
|
33
44
|
- .gitignore
|
34
45
|
homepage: https://github.com/tsmolka/vagrant-guest-msys2
|
35
46
|
licenses:
|