Run NVIDIA driver download attempts in a loop
This commit is contained in:
@@ -28,7 +28,6 @@ export intel_gpu_model="$(lspci | grep -i "VGA compatible controller: Intel" | c
|
||||
export amd_cpu_model="$(lscpu | grep 'Model name:' | grep -i amd | cut -d':' -f2 | xargs)"
|
||||
export amd_gpu_model="$(lspci | grep -i vga | grep -i amd)"
|
||||
|
||||
|
||||
function download_driver {
|
||||
local driver_url
|
||||
local stripped_version
|
||||
@@ -39,40 +38,31 @@ function download_driver {
|
||||
if [[ ! -f "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run" ]]; then
|
||||
print_step_header "Downloading driver v${nvidia_host_driver_version:?}"
|
||||
|
||||
# Try downloading from NVIDIA Global Server
|
||||
driver_url="http://download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version:?}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version:?}.run"
|
||||
if wget --spider --quiet "${driver_url:?}"; then
|
||||
wget -q --show-progress --progress=bar:force:noscroll \
|
||||
-O /tmp/NVIDIA.run \
|
||||
"${driver_url:?}"
|
||||
else
|
||||
print_warning "Unable to download driver from NVIDIA Global Server. Trying US Server..."
|
||||
# Try downloading from a list of NVIDIA driver hosting servers
|
||||
stripped_version="${nvidia_host_driver_version#v}" # Strip 'v' if present
|
||||
declare -a sources=(
|
||||
"http://download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version}.run"
|
||||
"http://us.download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version}.run"
|
||||
"https://github.com/flathub/org.freedesktop.Platform.GL.nvidia/releases/download/cuda/NVIDIA-Linux-x86_64-${stripped_version}.run"
|
||||
)
|
||||
|
||||
# If NVIDIA Global Server fails, try the US server
|
||||
driver_url="http://us.download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version:?}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version:?}.run"
|
||||
if wget --spider --quiet "${driver_url:?}"; then
|
||||
wget -q --show-progress --progress=bar:force:noscroll \
|
||||
for driver_url in "${sources[@]}"; do
|
||||
if wget -q --show-progress --progress=bar:force:noscroll \
|
||||
-O /tmp/NVIDIA.run \
|
||||
"${driver_url:?}"
|
||||
"${driver_url:?}"; then
|
||||
mv /tmp/NVIDIA.run "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run"
|
||||
return 0
|
||||
mv /tmp/NVIDIA.run "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run"
|
||||
return 0
|
||||
else
|
||||
print_warning "Unable to download driver from NVIDIA US Server. Trying GitHub..."
|
||||
print_warning "Download failed from: ${driver_url}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Finally, if both fail, try downloading from GitHub
|
||||
stripped_version="${nvidia_host_driver_version#v}" # Strip 'v' from the version if present
|
||||
driver_url="https://github.com/flathub/org.freedesktop.Platform.GL.nvidia/releases/download/cuda/NVIDIA-Linux-x86_64-${stripped_version:?}.run"
|
||||
if wget --spider --quiet "${driver_url:?}"; then
|
||||
wget -q --show-progress --progress=bar:force:noscroll \
|
||||
-O /tmp/NVIDIA.run \
|
||||
"${driver_url:?}"
|
||||
else
|
||||
print_error "Unable to download driver from any source. Exit!"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
mv /tmp/NVIDIA.run "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run"
|
||||
fi
|
||||
}
|
||||
|
||||
function install_nvidia_driver {
|
||||
@@ -160,7 +150,10 @@ function patch_nvidia_driver {
|
||||
PATCH_OUTPUT_DIR="/patched-lib" "${USER_HOME:?}/Downloads/nvidia-patch.${NVIDIA_PATCH_VERSION:?}.sh"
|
||||
PATCH_OUTPUT_DIR="/patched-lib" "${USER_HOME:?}/Downloads/nvidia-patch-fbc.${NVIDIA_PATCH_VERSION:?}.sh"
|
||||
|
||||
pushd "/patched-lib" &> /dev/null || { print_error "Failed to push directory to /patched-lib"; exit 1; }
|
||||
pushd "/patched-lib" &>/dev/null || {
|
||||
print_error "Failed to push directory to /patched-lib"
|
||||
exit 1
|
||||
}
|
||||
for f in *; do
|
||||
suffix="${f##*.so}"
|
||||
name="$(basename "$f" "$suffix")"
|
||||
@@ -168,7 +161,10 @@ function patch_nvidia_driver {
|
||||
[ -h "$name" ] || ln -sf "$f" "$name.1"
|
||||
done
|
||||
ldconfig
|
||||
popd &> /dev/null || { print_error "Failed to pop directory out of /patched-lib"; exit 1; }
|
||||
popd &>/dev/null || {
|
||||
print_error "Failed to pop directory out of /patched-lib"
|
||||
exit 1
|
||||
}
|
||||
)
|
||||
else
|
||||
print_step_header "Leaving NVIDIA driver stock without patching"
|
||||
|
||||
Reference in New Issue
Block a user