Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor out version check code into a separate script. Call the script… #199

Merged
merged 3 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions check-version.sh
Original file line number Diff line number Diff line change
@@ -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..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just stay quiet if operating system is correct. That's the default assumption. So only output anything if we're failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Done.

else
echo "Script execution failed due to system requirements not being met." >&2
exit 1
fi

3 changes: 3 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down