Merge pull request #7632 from mitchellh/sethvargo/ubuntu_detect

guests/ubuntu: Revert detection
This commit is contained in:
Seth Vargo 2016-07-23 15:18:53 -04:00 committed by GitHub
commit a732b355d2
1 changed files with 16 additions and 1 deletions

View File

@ -2,7 +2,22 @@ module VagrantPlugins
module GuestUbuntu module GuestUbuntu
class Guest < Vagrant.plugin("2", :guest) class Guest < Vagrant.plugin("2", :guest)
def detect?(machine) def detect?(machine)
machine.communicate.test("test -r /etc/os-release && . /etc/os-release && test xubuntu = x$ID") # This command detects if we are running on Ubuntu. /etc/os-release is
# available on modern Ubuntu versions, but does not exist on 14.04 and
# previous versions, so we fall back to lsb_release.
#
# GH-7524
# GH-7625
#
machine.communicate.test <<-EOH.gsub(/^ {10}/, "")
if test -r /etc/os-release; then
source /etc/os-release && test xubuntu = x$ID
elif test -x /usr/bin/lsb_release; then
/usr/bin/lsb_release -i 2>/dev/null | grep -q Ubuntu
else
exit 1
fi
EOH
end end
end end
end end