29 lines
615 B
Bash
Executable File
29 lines
615 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# detect.sh — distro + arch detection. Exports DISTRO and ARCH.
|
|
|
|
detect_distro() {
|
|
DISTRO="unknown"
|
|
ARCH="$(uname -m)"
|
|
case "$ARCH" in
|
|
x86_64) ARCH="amd64" ;;
|
|
aarch64|arm64) ARCH="arm64" ;;
|
|
esac
|
|
|
|
if [[ -f /etc/os-release ]]; then
|
|
# shellcheck disable=SC1091
|
|
. /etc/os-release
|
|
case "${ID:-}" in
|
|
debian|ubuntu) DISTRO="debian" ;;
|
|
arch) DISTRO="arch" ;;
|
|
*)
|
|
case "${ID_LIKE:-}" in
|
|
*debian*) DISTRO="debian" ;;
|
|
*arch*) DISTRO="arch" ;;
|
|
esac ;;
|
|
esac
|
|
fi
|
|
|
|
export DISTRO ARCH
|
|
}
|
|
|
|
detect_distro |