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_cpu_model="$(lscpu | grep 'Model name:' | grep -i amd | cut -d':' -f2 | xargs)"
|
||||||
export amd_gpu_model="$(lspci | grep -i vga | grep -i amd)"
|
export amd_gpu_model="$(lspci | grep -i vga | grep -i amd)"
|
||||||
|
|
||||||
|
|
||||||
function download_driver {
|
function download_driver {
|
||||||
local driver_url
|
local driver_url
|
||||||
local stripped_version
|
local stripped_version
|
||||||
@@ -39,40 +38,31 @@ function download_driver {
|
|||||||
if [[ ! -f "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run" ]]; then
|
if [[ ! -f "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run" ]]; then
|
||||||
print_step_header "Downloading driver v${nvidia_host_driver_version:?}"
|
print_step_header "Downloading driver v${nvidia_host_driver_version:?}"
|
||||||
|
|
||||||
# Try downloading from NVIDIA Global Server
|
# Try downloading from a list of NVIDIA driver hosting servers
|
||||||
driver_url="http://download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version:?}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version:?}.run"
|
stripped_version="${nvidia_host_driver_version#v}" # Strip 'v' if present
|
||||||
if wget --spider --quiet "${driver_url:?}"; then
|
declare -a sources=(
|
||||||
wget -q --show-progress --progress=bar:force:noscroll \
|
"http://download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version}.run"
|
||||||
-O /tmp/NVIDIA.run \
|
"http://us.download.nvidia.com/XFree86/Linux-x86_64/${nvidia_host_driver_version}/NVIDIA-Linux-x86_64-${nvidia_host_driver_version}.run"
|
||||||
"${driver_url:?}"
|
"https://github.com/flathub/org.freedesktop.Platform.GL.nvidia/releases/download/cuda/NVIDIA-Linux-x86_64-${stripped_version}.run"
|
||||||
else
|
)
|
||||||
print_warning "Unable to download driver from NVIDIA Global Server. Trying US Server..."
|
|
||||||
|
|
||||||
# If NVIDIA Global Server fails, try the US server
|
for driver_url in "${sources[@]}"; do
|
||||||
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 -q --show-progress --progress=bar:force:noscroll \
|
||||||
if wget --spider --quiet "${driver_url:?}"; then
|
|
||||||
wget -q --show-progress --progress=bar:force:noscroll \
|
|
||||||
-O /tmp/NVIDIA.run \
|
-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
|
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!"
|
print_error "Unable to download driver from any source. Exit!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
mv /tmp/NVIDIA.run "${USER_HOME:?}/Downloads/NVIDIA_${nvidia_host_driver_version:?}.run"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_nvidia_driver {
|
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.${NVIDIA_PATCH_VERSION:?}.sh"
|
||||||
PATCH_OUTPUT_DIR="/patched-lib" "${USER_HOME:?}/Downloads/nvidia-patch-fbc.${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
|
for f in *; do
|
||||||
suffix="${f##*.so}"
|
suffix="${f##*.so}"
|
||||||
name="$(basename "$f" "$suffix")"
|
name="$(basename "$f" "$suffix")"
|
||||||
@@ -168,7 +161,10 @@ function patch_nvidia_driver {
|
|||||||
[ -h "$name" ] || ln -sf "$f" "$name.1"
|
[ -h "$name" ] || ln -sf "$f" "$name.1"
|
||||||
done
|
done
|
||||||
ldconfig
|
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
|
else
|
||||||
print_step_header "Leaving NVIDIA driver stock without patching"
|
print_step_header "Leaving NVIDIA driver stock without patching"
|
||||||
|
|||||||
Reference in New Issue
Block a user