# Created on savesnippets.com · https://savesnippets.com/KHSZ9FDd3BrwOF # Source the file — it sets shell variables . /etc/os-release echo "Distro: $NAME" echo "Version: $VERSION_ID" echo "ID: $ID" echo "Codename: $VERSION_CODENAME" # Branch on distro case "$ID" in ubuntu|debian) apt update && apt install -y "$@" ;; rhel|centos|fedora|rocky|almalinux) dnf install -y "$@" || yum install -y "$@" ;; alpine) apk add --no-cache "$@" ;; *) echo "Unsupported distro: $ID" >&2; exit 1 ;; esac # Detect macOS [[ "$(uname)" == "Darwin" ]] && echo "macOS" # Detect WSL grep -qi microsoft /proc/version 2>/dev/null && echo "WSL"