2023-08-10 16:53:25 -04:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2012-04-19 00:03:03 -04:00
|
|
|
module VagrantPlugins
|
|
|
|
|
module GuestLinux
|
2012-11-07 00:14:45 -05:00
|
|
|
class Guest < Vagrant.plugin("2", :guest)
|
2016-10-11 10:50:34 -04:00
|
|
|
# Name used for guest detection
|
|
|
|
|
GUEST_DETECTION_NAME = "linux".freeze
|
|
|
|
|
|
2013-04-04 00:47:57 -04:00
|
|
|
def detect?(machine)
|
2016-10-11 10:50:34 -04:00
|
|
|
machine.communicate.test <<-EOH.gsub(/^ */, '')
|
|
|
|
|
if test -r /etc/os-release; then
|
2016-12-07 04:04:33 -05:00
|
|
|
source /etc/os-release && test 'x#{self.class.const_get(:GUEST_DETECTION_NAME)}' = "x$ID" && exit
|
2016-10-11 10:50:34 -04:00
|
|
|
fi
|
|
|
|
|
if test -x /usr/bin/lsb_release; then
|
2016-12-07 04:04:33 -05:00
|
|
|
/usr/bin/lsb_release -i 2>/dev/null | grep -qi '#{self.class.const_get(:GUEST_DETECTION_NAME)}' && exit
|
2016-10-11 10:50:34 -04:00
|
|
|
fi
|
|
|
|
|
if test -r /etc/issue; then
|
2016-12-07 04:04:33 -05:00
|
|
|
cat /etc/issue | grep -qi '#{self.class.const_get(:GUEST_DETECTION_NAME)}' && exit
|
2016-10-11 10:50:34 -04:00
|
|
|
fi
|
|
|
|
|
exit 1
|
|
|
|
|
EOH
|
2013-04-04 00:47:57 -04:00
|
|
|
end
|
2010-09-01 13:00:49 -04:00
|
|
|
end
|
2010-04-25 04:46:51 -04:00
|
|
|
end
|
2010-05-18 04:24:59 -04:00
|
|
|
end
|