2012-04-19 04:03:03 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module GuestLinux
|
2012-11-07 05:14:45 +00:00
|
|
|
class Guest < Vagrant.plugin("2", :guest)
|
2016-10-11 14:50:34 +00:00
|
|
|
# Name used for guest detection
|
|
|
|
GUEST_DETECTION_NAME = "linux".freeze
|
|
|
|
|
2013-04-04 04:47:57 +00:00
|
|
|
def detect?(machine)
|
2016-10-11 14:50:34 +00:00
|
|
|
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
|
2013-04-04 04:47:57 +00:00
|
|
|
end
|
2010-09-01 17:00:49 +00:00
|
|
|
end
|
2010-04-25 08:46:51 +00:00
|
|
|
end
|
2010-05-18 08:24:59 +00:00
|
|
|
end
|