From 1b036342a2cce09272f2cb8398047c040ecbf295 Mon Sep 17 00:00:00 2001 From: javajosh Date: Tue, 9 Jul 2024 10:15:31 -0400 Subject: [PATCH] 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 0000000..1cb1f70 --- /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 4ee2111..bf3816a 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