vagrant-goodhosts 1.1.8 → 1.1.9
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-goodhosts/GoodHosts.rb +24 -12
- data/lib/vagrant-goodhosts/bundle/cli.exe +0 -0
- data/lib/vagrant-goodhosts/bundle/cli_amd64_linux +0 -0
- data/lib/vagrant-goodhosts/bundle/cli_amd64_osx +0 -0
- data/lib/vagrant-goodhosts/bundle/cli_arm64_linux +0 -0
- data/lib/vagrant-goodhosts/bundle/cli_arm64_osx +0 -0
- data/lib/vagrant-goodhosts/version.rb +1 -1
- data/package.sh +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ef42ed7a5e7aceee9728b236457f28a23a9d041e7380733ceccaa375d1bb3336
|
|
4
|
+
data.tar.gz: 05d903561e67e846b6392f5c460edef92122c89404a15db654fb27c4071d1ded
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: caae13a327c9677e1db6cb2b25c41a285eb63af9a62a21f6f9caeb5257986ebbaaf4cca436b7470879091586aa81b430a4edd49201eb97befae0eafeac3377ca
|
|
7
|
+
data.tar.gz: 2ab4ef0e085dba2d3b25fb9e09e576863e9cce00e6f2488b2772ea143b91421d1b22937aa2185c8b6fe37a969d3b3d435090119acbd9e47d821498160566a31a
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# The core of the plugin
|
|
2
2
|
require "rbconfig"
|
|
3
3
|
require "open3"
|
|
4
|
-
require "resolv"
|
|
5
4
|
require "os"
|
|
6
5
|
|
|
7
6
|
module VagrantPlugins
|
|
@@ -98,22 +97,35 @@ module VagrantPlugins
|
|
|
98
97
|
return true
|
|
99
98
|
end
|
|
100
99
|
|
|
100
|
+
# Check if a specific IP/hostname mapping exists in the hosts file
|
|
101
|
+
# Uses the CLI check command instead of DNS resolution
|
|
102
|
+
def hosts_entry_exists?(ip_address, hostname)
|
|
103
|
+
cli = get_cli
|
|
104
|
+
# Use check command - no sudo needed for read-only operation
|
|
105
|
+
if cli.include? ".exe"
|
|
106
|
+
# Windows: direct command execution
|
|
107
|
+
_stdout, _stderr, status = Open3.capture3("\"#{cli}\" check \"#{ip_address}\" \"#{hostname}\"")
|
|
108
|
+
else
|
|
109
|
+
# Unix/macOS: no sudo needed for check
|
|
110
|
+
_stdout, _stderr, status = Open3.capture3("'#{cli}' check '#{ip_address}' '#{hostname}'")
|
|
111
|
+
end
|
|
112
|
+
return status.success?
|
|
113
|
+
rescue StandardError => e
|
|
114
|
+
@ui.warn "[vagrant-goodhosts] Error checking host entry: #{e.message}"
|
|
115
|
+
return false
|
|
116
|
+
end
|
|
117
|
+
|
|
101
118
|
def check_hostnames_to_add(ip_address, hostnames)
|
|
102
119
|
hostnames_to_add = Array.new
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if address != ip_address
|
|
109
|
-
hostnames_to_add.append(hostname)
|
|
110
|
-
end
|
|
111
|
-
rescue StandardError => _e
|
|
120
|
+
hostnames_arr = hostnames.split
|
|
121
|
+
|
|
122
|
+
# Check each hostname using the CLI check command
|
|
123
|
+
hostnames_arr.each do |hostname|
|
|
124
|
+
unless hosts_entry_exists?(ip_address, hostname)
|
|
112
125
|
hostnames_to_add.append(hostname)
|
|
113
126
|
end
|
|
114
|
-
rescue StandardError => _e
|
|
115
|
-
hostnames_to_add.append(hostname)
|
|
116
127
|
end
|
|
128
|
+
|
|
117
129
|
return hostnames_to_add.join(' ')
|
|
118
130
|
end
|
|
119
131
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/package.sh
CHANGED
|
@@ -5,11 +5,11 @@ cd ./lib/vagrant-goodhosts/bundle
|
|
|
5
5
|
# Download
|
|
6
6
|
curl -s https://api.github.com/repos/goodhosts/cli/releases/latest | jq --raw-output '.assets[] | .browser_download_url' | xargs wget -i
|
|
7
7
|
# Extract
|
|
8
|
-
tar -zxvf goodhosts-1.1.
|
|
9
|
-
tar -zxvf goodhosts-1.1.
|
|
10
|
-
tar -zxvf goodhosts-1.1.
|
|
11
|
-
tar -zxvf goodhosts-1.1.
|
|
12
|
-
tar -zxvf goodhosts-1.1.
|
|
8
|
+
tar -zxvf goodhosts-1.1.3-darwin-amd64.tar.gz goodhosts && mv goodhosts cli_amd64_osx
|
|
9
|
+
tar -zxvf goodhosts-1.1.3-darwin-arm64.tar.gz goodhosts && mv goodhosts cli_arm64_osx
|
|
10
|
+
tar -zxvf goodhosts-1.1.3-linux-amd64.tar.gz goodhosts && mv goodhosts cli_amd64_linux
|
|
11
|
+
tar -zxvf goodhosts-1.1.3-linux-arm64.tar.gz goodhosts && mv goodhosts cli_arm64_linux
|
|
12
|
+
tar -zxvf goodhosts-1.1.3-windows-amd64.tar.gz goodhosts.exe && mv goodhosts.exe cli.exe
|
|
13
13
|
rm -f ./*.tar.gz
|
|
14
14
|
rm -f ./*.txt
|
|
15
15
|
# Generate
|