From 1b036342a2cce09272f2cb8398047c040ecbf295 Mon Sep 17 00:00:00 2001 From: javajosh Date: Tue, 9 Jul 2024 10:15:31 -0400 Subject: [PATCH 1/2] Factor out version check code into a separate script. Call the script in install.sh after the omakub clone in boot.sh --- check-version.sh | 30 ++++++++++++++++++++++++++++++ install.sh | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 check-version.sh diff --git a/check-version.sh b/check-version.sh new file mode 100644 index 00000000..1cb1f70d --- /dev/null +++ b/check-version.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Function to check if running on Ubuntu 24.04 or higher +check_ubuntu_version() { + if [ -f /etc/os-release ]; then + . /etc/os-release + if [ "$ID" = "ubuntu" ]; then + if awk -v ver="$VERSION_ID" 'BEGIN {exit !(ver >= 24.04)}'; then + return 0 + else + echo "Error: Ubuntu version must be 24.04 or higher. Current version: $VERSION_ID" >&2 + return 1 + fi + else + echo "Error: This script must be run on Ubuntu. Current OS: $ID" >&2 + return 1 + fi + else + echo "Error: Unable to determine OS. /etc/os-release file not found." >&2 + return 1 + fi +} + +if check_ubuntu_version; then + echo "Script is running on Ubuntu 24.04 or higher. Continuing execution..." +else + echo "Script execution failed due to system requirements not being met." >&2 + exit 1 +fi + diff --git a/install.sh b/install.sh index 4ee21111..bf3816a7 100644 --- a/install.sh +++ b/install.sh @@ -4,6 +4,9 @@ set -e # Desktop software and tweaks will only be installed if we're running Gnome RUNNING_GNOME=$([[ "$XDG_CURRENT_DESKTOP" == *"GNOME"* ]] && echo true || echo false) +# Check the distribution name and version and abort if incompatible +source ~/.local/share/omakub/check-version.sh + if $RUNNING_GNOME; then # Ensure computer doesn't go to sleep or lock while installing gsettings set org.gnome.desktop.screensaver lock-enabled false From a43dfdffd7a9f0885cf8c0a7f7791c00c932f71f Mon Sep 17 00:00:00 2001 From: javajosh Date: Fri, 12 Jul 2024 12:36:01 -0400 Subject: [PATCH 2/2] Remain silent on successful version check. --- check-version.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/check-version.sh b/check-version.sh index 1cb1f70d..c3bad772 100644 --- a/check-version.sh +++ b/check-version.sh @@ -21,9 +21,7 @@ check_ubuntu_version() { fi } -if check_ubuntu_version; then - echo "Script is running on Ubuntu 24.04 or higher. Continuing execution..." -else +if ! check_ubuntu_version; then echo "Script execution failed due to system requirements not being met." >&2 exit 1 fi