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

Refactor check-version script #244

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Changes from all commits
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
37 changes: 14 additions & 23 deletions install/check-version.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
#!/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 [ ! -f /etc/os-release ]; then
echo "$(tput setaf 1)Error: Unable to determine OS. /etc/os-release file not found."
echo "Installation stopped."
exit 1
fi

. /etc/os-release

if ! check_ubuntu_version; then
echo "Script execution failed due to system requirements not being met." >&2
exit 1
# Check if running on Ubuntu 24.04 or higher
if [ "$ID" != "ubuntu" ] || [ $(echo "$VERSION_ID >= 24.04" | bc) != 1 ]; then
echo "$(tput setaf 1)Error: OS requirement not met"
echo "You are currently running: $ID $VERSION_ID"
echo "OS required: ubuntu 24.04 or higher"
echo "Installation stopped."
exit 1
fi