From 00fa49191dba2bb7c6322fa8df9327ca505c0b41 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sat, 23 Jul 2016 11:40:36 -0400 Subject: [PATCH] guests/ubuntu: Revert detection - Semi-reverts GH-7524 - Fixes GH-7625 --- plugins/guests/ubuntu/guest.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/guests/ubuntu/guest.rb b/plugins/guests/ubuntu/guest.rb index 9aeb7aa8a..f60108eab 100644 --- a/plugins/guests/ubuntu/guest.rb +++ b/plugins/guests/ubuntu/guest.rb @@ -2,7 +2,22 @@ module VagrantPlugins module GuestUbuntu class Guest < Vagrant.plugin("2", :guest) 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