From 357fed30704954ef48d0557d4571a43b8dff5f6d Mon Sep 17 00:00:00 2001 From: MVDW Date: Mon, 26 Aug 2024 18:09:56 +0200 Subject: [PATCH 1/2] Update preflight.sh --- setup/preflight.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setup/preflight.sh b/setup/preflight.sh index 2105ebecc..a4e7b5cf5 100644 --- a/setup/preflight.sh +++ b/setup/preflight.sh @@ -8,11 +8,13 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -# Check that we are running on Ubuntu 20.04 LTS (or 20.04.xx). -if [ "$( lsb_release --id --short )" != "Ubuntu" ] || [ "$( lsb_release --release --short )" != "22.04" ]; then +. /etc/os-release + +# Check that we are running on Ubuntu 22.04 LTS (or 22.04.xx). +if [ "${ID:-}" != "ubuntu" ] || [ "${VERSION_ID:-}" != "22.04" ]; then echo "Mail-in-a-Box only supports being installed on Ubuntu 22.04, sorry. You are running:" echo - lsb_release --description --short + echo "${ID:-"Unknown linux distribution"} ${VERSION_ID:-}" echo echo "We can't write scripts that run on every possible setup, sorry." exit 1 From 3decfcdbd85aa6fc4f304b74721d39a08ff875aa Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 22 Dec 2024 07:37:27 -0500 Subject: [PATCH 2/2] Try namespacing the variables pulled in from /etc/os-release Kind of like https://unix.stackexchange.com/a/477443. --- setup/preflight.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup/preflight.sh b/setup/preflight.sh index a4e7b5cf5..600b4188e 100644 --- a/setup/preflight.sh +++ b/setup/preflight.sh @@ -8,13 +8,14 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -. /etc/os-release - # Check that we are running on Ubuntu 22.04 LTS (or 22.04.xx). -if [ "${ID:-}" != "ubuntu" ] || [ "${VERSION_ID:-}" != "22.04" ]; then +# Pull in the variables defined in /etc/os-release but in a +# namespace to avoid polluting our variables. +source <(cat /etc/os-release | sed s/^/OS_RELEASE_/) +if [ "${OS_RELEASE_ID:-}" != "ubuntu" ] || [ "${OS_RELEASE_VERSION_ID:-}" != "22.04" ]; then echo "Mail-in-a-Box only supports being installed on Ubuntu 22.04, sorry. You are running:" echo - echo "${ID:-"Unknown linux distribution"} ${VERSION_ID:-}" + echo "${OS_RELEASE_ID:-"Unknown linux distribution"} ${OS_RELEASE_VERSION_ID:-}" echo echo "We can't write scripts that run on every possible setup, sorry." exit 1