Auto detect Distro
This commit is contained in:
+38
-2
@@ -1,13 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
VBOX_VERSION='7.1'
|
||||
DISTRO='noble'
|
||||
VBOX_PACKAGE="virtualbox-$VBOX_VERSION"
|
||||
FINGERPRINT_VBOX='B9F8 D658 297A F3EF C18D 5CDF A2F6 83C5 2980 AECF'
|
||||
VBOX_PUBKEY_LOCATION='/usr/share/keyrings/oracle-virtualbox-2016.gpg'
|
||||
VBOX_PUBKEY_LINK='https://www.virtualbox.org/download/oracle_vbox_2016.asc'
|
||||
SOURCE_LIST="deb [arch=amd64 signed-by=$VBOX_PUBKEY_LOCATION] https://download.virtualbox.org/virtualbox/debian $DISTRO contrib"
|
||||
|
||||
if [ ! -f /etc/os-release ]; then
|
||||
echo "[Error] /etc/os-release not found, cannot detect distro"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/os-release
|
||||
|
||||
IS_DEBIAN_LIKE=false
|
||||
|
||||
case "$ID" in
|
||||
debian|ubuntu) IS_DEBIAN_LIKE=true ;;
|
||||
esac
|
||||
|
||||
if [ "$IS_DEBIAN_LIKE" = false ]; then
|
||||
case " ${ID_LIKE:-} " in
|
||||
*debian*|*ubuntu*) IS_DEBIAN_LIKE=true ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ "$IS_DEBIAN_LIKE" = false ]; then
|
||||
echo "[Error] Detected distro '$PRETTY_NAME' is not Debian/Ubuntu based. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# On derivatives (e.g. Linux Mint, LMDE) VERSION_CODENAME is the
|
||||
# distro's own codename and isn't recognized by the VirtualBox repo.
|
||||
# Prefer the upstream Ubuntu/Debian codename when the distro exposes one.
|
||||
DISTRO="${UBUNTU_CODENAME:-${DEBIAN_CODENAME:-$VERSION_CODENAME}}"
|
||||
|
||||
echo "Detected distro: $PRETTY_NAME (ID=$ID, base codename=$DISTRO)"
|
||||
read -r -p "Is this correct? Continue with VirtualBox installation for '$DISTRO'? [y/N] " CONFIRM
|
||||
case "$CONFIRM" in
|
||||
y|Y|yes|YES) ;;
|
||||
*) echo "Aborted by user."; exit 1 ;;
|
||||
esac
|
||||
|
||||
SOURCE_LIST="deb [arch=amd64 signed-by=$VBOX_PUBKEY_LOCATION] https://download.virtualbox.org/virtualbox/debian $DISTRO contrib"
|
||||
|
||||
sudo apt update && sudo apt install -y wget gpg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user