vagrant/plugins/guests/linux/guest.rb

24 lines
800 B
Ruby
Raw Normal View History

module VagrantPlugins
module GuestLinux
2012-11-07 05:14:45 +00:00
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
2016-12-07 09:04:33 +00:00
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
2016-12-07 09:04:33 +00:00
/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
2016-12-07 09:04:33 +00:00
cat /etc/issue | grep -qi '#{self.class.const_get(:GUEST_DETECTION_NAME)}' && exit
fi
exit 1
EOH
end
end
end
2010-05-18 08:24:59 +00:00
end