vagrant/plugins/guests/linux/guest.rb
oss-core-libraries-dashboard[bot] 206f8102c9
[COMPLIANCE] Update Copyright and License Headers (Batch 2 of 7) (#13761)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2025-12-22 16:46:17 +05:30

26 lines
870 B
Ruby

# Copyright IBM Corp. 2010, 2025
# SPDX-License-Identifier: BUSL-1.1
module VagrantPlugins
module GuestLinux
class Guest < Vagrant.plugin("2", :guest)
# Name used for guest detection
GUEST_DETECTION_NAME = "linux".freeze
def detect?(machine)
machine.communicate.test <<-EOH.gsub(/^ */, '')
if test -r /etc/os-release; then
source /etc/os-release && test 'x#{self.class.const_get(:GUEST_DETECTION_NAME)}' = "x$ID" && exit
fi
if test -x /usr/bin/lsb_release; then
/usr/bin/lsb_release -i 2>/dev/null | grep -qi '#{self.class.const_get(:GUEST_DETECTION_NAME)}' && exit
fi
if test -r /etc/issue; then
cat /etc/issue | grep -qi '#{self.class.const_get(:GUEST_DETECTION_NAME)}' && exit
fi
exit 1
EOH
end
end
end
end