2022-03-17 10:14:08 +01:00
|
|
|
#!/bin/bash
|
2022-02-25 16:33:46 +01:00
|
|
|
|
2022-03-23 08:33:44 +01:00
|
|
|
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts"
|
2022-03-23 08:16:01 +01:00
|
|
|
|
2022-03-01 13:55:05 +01:00
|
|
|
# abort if not executed as root
|
2022-02-25 16:33:46 +01:00
|
|
|
if [[ $(id -u) != "0" ]]; then
|
|
|
|
echo "Error: Run ${0##*/} as root" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2022-03-23 08:16:01 +01:00
|
|
|
SYSTEM_ARCH=$("$(dirname "$0")/arch.sh")
|
2022-02-25 16:33:46 +01:00
|
|
|
DESTARCH=${DESTARCH:-$SYSTEM_ARCH}
|
|
|
|
TMPDIR=${TMPDIR:-/tmp}
|
|
|
|
. /etc/os-release
|
|
|
|
|
|
|
|
if [[ $DESTARCH != "amd64" ]]; then
|
|
|
|
echo "Installing GPU drivers for ${DESTARCH} is not supported yet."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-03-23 08:16:01 +01:00
|
|
|
apt-get update
|
|
|
|
apt-get -qq upgrade
|
|
|
|
apt-get -qq install lshw jq
|
2022-02-25 16:33:46 +01:00
|
|
|
|
|
|
|
# shellcheck disable=SC2207
|
2022-03-23 08:16:01 +01:00
|
|
|
GPU_DETECTED=($(lshw -c display -json 2>/dev/null | jq -r '.[].configuration.driver'))
|
2022-02-25 16:33:46 +01:00
|
|
|
|
|
|
|
# shellcheck disable=SC2068
|
|
|
|
for t in ${GPU_DETECTED[@]}; do
|
|
|
|
case $t in
|
|
|
|
i915)
|
2022-03-23 08:16:01 +01:00
|
|
|
apt-get -qq install intel-opencl-icd intel-media-va-driver-non-free i965-va-driver-shaders libmfx1 libva2 vainfo libva-wayland2
|
2022-02-25 16:33:46 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
nvidia)
|
2022-03-23 13:27:25 +01:00
|
|
|
apt-get -qq install nvidia-opencl-icd nvidia-vdpau-driver nvidia-driver-libs nvidia-kernel-dkms libva2 vainfo libva-wayland2 libnvidia-encode1
|
|
|
|
;;
|
|
|
|
|
|
|
|
null)
|
|
|
|
# ignore
|
2022-02-25 16:33:46 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Unsupported GPU: \"$t\"";
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Done."
|