Last active
February 15, 2025 06:01
-
-
Save psiborg/a4ed725a18809c388441dd701c3f11bc to your computer and use it in GitHub Desktop.
Linux Distro Checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Log and data files | |
LOG_FILE="distro_checker.log" | |
DATA_FILE="distro_versions.txt" | |
# Source the external distro configuration file | |
source "./distro_checker_config.sh" | |
# Function to fetch and extract version information | |
fetch_version() { | |
local url=$1 | |
local opts=$2 | |
local regex=$3 | |
echo "Executing: curl $opts -s \"$url\"" >> "$LOG_FILE" | |
curl $opts -s "$url" | grep -oP -m1 "$regex" | |
} | |
# Load previous versions into an associative array | |
declare -A previous_versions | |
if [[ -f "$DATA_FILE" ]]; then | |
while IFS='|' read -r distro prev_version curr_version; do | |
previous_versions[$distro]="$curr_version" | |
done < <(tail -n +2 "$DATA_FILE") | |
fi | |
# Fetch and store current versions | |
declare -A current_versions | |
echo "Fetching version info..." | |
echo | |
for distro in $(printf "%s\n" "${!distros[@]}" | sort); do | |
eval "${distros[$distro]}" | |
version=$(fetch_version "$url" "$opts" "$regex") | |
if [[ -n $version ]]; then | |
current_versions[$distro]="$version" | |
else | |
current_versions[$distro]="N/A" | |
fi | |
done | |
# Save results to file with timestamp | |
echo "Distro Name|Previous Version|Current Version" > "$DATA_FILE" | |
for distro in $(printf "%s\n" "${!distros[@]}" | sort); do | |
prev_version="${previous_versions[$distro]}" | |
curr_version="${current_versions[$distro]}" | |
echo "$distro|${prev_version:- }|$curr_version" >> "$DATA_FILE" | |
done | |
echo "Last Checked: $(date)" >> "$DATA_FILE" | |
# Display results in table format | |
echo "---------------------------+------------------------+------------------------" | |
echo " Distro Name | Previous Version | Current Version " | |
echo "---------------------------+------------------------+------------------------" | |
while IFS='|' read -r distro prev_version curr_version; do | |
printf "%-26s | %-22s | %s\n" "$distro" "${prev_version:- }" "$curr_version" | |
done < <(tail -n +2 "$DATA_FILE" | head -n -1) | |
echo | |
cat "$DATA_FILE" | tail -n 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define an associative array with distro configurations | |
declare -A distros | |
# Define your distros and regex scraping details here | |
# Arch | |
distros["ArchLinux"]=$(cat <<EOF | |
url="https://archlinux.org/download/" | |
opts="--compressed" | |
regex="(?<=<strong>Current Release:</strong> ).*?(?=</li>)" | |
EOF | |
) | |
distros["CachyOS"]=$(cat <<EOF | |
url="https://cachyos.org/download/" | |
opts="--compressed" | |
regex="(?<=https://cdn77.cachyos.org/ISO/desktop/).*?(?=/cachyos-desktop-linux-)" | |
EOF | |
) | |
distros["EndeavourOS"]=$(cat <<EOF | |
url="https://endeavouros.com/" | |
opts="--compressed" | |
regex="(?<=<a href=\"https://mirrors.gigenet.com/endeavouros/iso/EndeavourOS_Endeavour_neo-).*?(?=.iso\">Download</a>)" | |
EOF | |
) | |
distros["Garuda"]=$(cat <<EOF | |
url="https://iso.builds.garudalinux.org/iso/latest/garuda/dr460nized/latest.iso?r2=1" | |
opts="--head" | |
regex="(?<=location: https://iso.builds.garudalinux.org/iso/garuda/dr460nized/).*?(?=/garuda-dr460nized-linux-zen-)" | |
EOF | |
) | |
distros["Manjaro"]=$(cat <<EOF | |
url="https://manjaro.org/products/download/x86" | |
opts="-L" | |
regex="(?<=<a href=\"https://download.manjaro.org/kde/).*?(?=/manjaro-kde-)" | |
EOF | |
) | |
# Debian | |
distros["Debian"]=$(cat <<EOF | |
url='https://www.debian.org/CD/http-ftp/#stable' | |
opts='--compressed' | |
regex='(?<=the current release of the "stable" USB/CD/DVD images is <strong>).*?(?=</strong>)' | |
EOF | |
) | |
distros["CommodoreOS"]=$(cat <<EOF | |
url='https://www.commodoreos.net/CommodoreOS.aspx' | |
opts='--compressed' | |
regex='(?<=<a href="Downloads/CommodoreOS-).*?(?=.torrent")' | |
EOF | |
) | |
distros["elementaryOS"]=$(cat <<EOF | |
url='https://elementary.io/' | |
opts='--compressed' | |
regex='(?<=/elementaryos-).*?(?=.iso">Download</a>)' | |
EOF | |
) | |
distros["Kali"]=$(cat <<EOF | |
url='https://www.kali.org/get-kali/#kali-installer-images' | |
opts='--compressed' | |
regex='(?<=<a href=https://cdimage.kali.org/kali-).*?(?=/kali-linux-)' | |
EOF | |
) | |
distros["LinuxMint"]=$(cat <<EOF | |
url='https://linuxmint.com/edition.php?id=316' | |
opts='--compressed' | |
regex='(?<=<a href="https://mirror.csclub.uwaterloo.ca/linuxmint/stable/).*?(?=/linuxmint-)' | |
EOF | |
) | |
distros["MXLinux"]=$(cat <<EOF | |
url='https://mxlinux.org/download-links/' | |
opts='--compressed' | |
regex='(?<=Current Release: MX-).*?(?=</h2>)' | |
EOF | |
) | |
distros["ParrotSecurity"]=$(cat <<EOF | |
url='https://parrotsec.org' | |
opts='--compressed' | |
regex='(?<=href="/download/">Download ParrotOS ).*?(?=</a>)' | |
EOF | |
) | |
distros["Pop!_OS"]=$(cat <<EOF | |
url='https://github.com/orgs/pop-os/projects/21' | |
opts='--compressed' | |
regex='(?<=<title>Pop!_OS ).*?(?= · GitHub</title>)' | |
EOF | |
) | |
distros["OSGeoLive"]=$(cat <<EOF | |
url='https://live.osgeo.org/en/download.html' | |
opts='--compressed' | |
regex='(?<=<p>The latest stable release is OSGeoLive ).*?(?= and can be downloaded from:</p>)' | |
EOF | |
) | |
distros["Q4OS"]=$(cat <<EOF | |
url='https://q4os.org/downloads1.html' | |
opts='--compressed' | |
regex='(?<=q4os-).*?(?=-x64.r1.iso<br />)' | |
EOF | |
) | |
distros["Tails"]=$(cat <<EOF | |
url='https://tails.net/install/download/index.en.html' | |
opts='--compressed' | |
regex='(?<=https://download.tails.net/tails/stable/tails-amd64-).*?(?=/tails-amd64-)' | |
EOF | |
) | |
distros["UbuntuLTS"]=$(cat <<EOF | |
url='https://ubuntu.com/download/desktop' | |
opts='--compressed' | |
regex='(?<=href="/download/desktop/thank-you\?version=).*?(?=&architecture=amd64<s=true")' | |
EOF | |
) | |
distros["Ubuntu"]=$(cat <<EOF | |
url='https://ubuntu.com/download/desktop' | |
opts='--compressed' | |
regex='(?<=href="/download/desktop/thank-you\?version=).*?(?=&architecture=amd64")' | |
EOF | |
) | |
distros["UbuntuStudioLTS"]=$(cat <<EOF | |
url='https://ubuntustudio.org/download/' | |
opts='--compressed' | |
regex='(?<=<h2>Ubuntu Studio )\d+\.\d+(?:\.\d+)?(?= LTS</h2>)' | |
EOF | |
) | |
distros["UbuntuStudio"]=$(cat <<EOF | |
url='https://ubuntustudio.org/download/' | |
opts='--compressed' | |
regex='(?<=<h2>Ubuntu Studio )\d+\.\d+(?:\.\d+)?(?=</h2>)' | |
EOF | |
) | |
distros["Wubuntu"]=$(cat <<EOF | |
url='https://wubuntu.org/download/' | |
opts='--compressed' | |
regex='(?<=<strong>Wubuntu ).*?(?= LTS)' | |
EOF | |
) | |
# Fedora | |
distros["Fedora"]=$(cat <<EOF | |
url='https://fedoraproject.org/workstation/download' | |
opts='-L' | |
regex='(?<=<a href="https://download.fedoraproject.org/pub/fedora/linux/releases/).*?(?=/Workstation/x86_64/iso/)' | |
EOF | |
) | |
distros["AlmaLinux"]=$(cat <<EOF | |
url='https://almalinux.org/get-almalinux/' | |
opts='--compressed' | |
regex='(?<=<a href=https://repo.almalinux.org/almalinux/).*?(?=/isos/x86_64/AlmaLinux-.*-x86_64-dvd.iso>)' | |
EOF | |
) | |
distros["Qubes"]=$(cat <<EOF | |
url='https://www.qubes-os.org/downloads/' | |
opts='--compressed' | |
regex='(?<=">Qubes OS ).*?(?=</h3>)' | |
EOF | |
) | |
# Other | |
distros["Alpine"]=$(cat <<EOF | |
url='https://www.alpinelinux.org/downloads/' | |
opts='--compressed' | |
regex='(?<=<p>Current Alpine Version <strong>).*?(?=</strong>)' | |
EOF | |
) | |
distros["RaspberryPiOS"]=$(cat <<EOF | |
url='https://downloads.raspberrypi.com/raspios_arm64/release_notes.txt' | |
opts='--compressed' | |
regex='^\d{4}-\d{2}-\d{2}(?=:)' | |
EOF | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment