setup-nvidia: Make "current" symlink logic more robust

Users have reported that in some cases the nvidia.service fails because
/opt/nvidia/current is a directory and the symbolic link gets created inside
it. I have no idea how we get there, but to make the service robust in the face
of this kind of issue:

- remove the directory if it exists
- use `-T` with ln to ensure that symbolic link creation fails if `current` is a directory

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
This commit is contained in:
Jeremi Piotrowski 2025-02-14 15:00:46 +01:00
parent 3c4c7c6cb0
commit 03925e1ca3

View File

@ -88,7 +88,11 @@ SYSEXT_LEVEL=1.0
EOF EOF
pushd /opt/nvidia pushd /opt/nvidia
ln -sfn "${NVIDIA_FLATCAR_VERSION_PAIR}" current if [[ -d "${NVIDIA_CURRENT_INSTALLATION}" ]]
then
rm -rf "${NVIDIA_CURRENT_INSTALLATION}"
fi
ln -sfn -T "${NVIDIA_FLATCAR_VERSION_PAIR}" "${NVIDIA_CURRENT_INSTALLATION}"
popd popd
} }