File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ EnvironmentFile=-/etc/nvidia-container-toolkit/nvidia-cdi-refresh.env
2626ExecCondition =/usr/bin/grep -qE '/nvidia.ko' /lib/modules/%v/modules.dep
2727ExecStart =/usr/bin/nvidia-ctk cdi generate
2828CapabilityBoundingSet =CAP_SYS_MODULE CAP_SYS_ADMIN CAP_MKNOD
29+ RemainAfterExit =yes
2930
3031[Install]
3132WantedBy =multi-user.target
Original file line number Diff line number Diff line change 9797 # remove the generated files
9898 rm /var/run/cdi/nvidia.yaml /tmp/nvidia.yaml
9999
100- # Touch the nvidia-ctk binary to change the mtime
101- # This will trigger the nvidia-cdi-refresh.path unit to call the
102- # nvidia-cdi-refresh.service unit, simulating a change(update/downgrade) in the nvidia-ctk binary.
103- touch $(which nvidia-ctk)
104-
105- # wait for 3 seconds
100+ # Simulate a binary upgrade by removing and recreating the file
101+ # This mimics package manager behavior during upgrades
102+ NVIDIA_CTK_PATH=$(which nvidia-ctk)
103+ # Create a backup
104+ cp "${NVIDIA_CTK_PATH}" "${NVIDIA_CTK_PATH}.backup"
105+ # Remove the original (simulating uninstall/upgrade phase)
106+ rm -f "${NVIDIA_CTK_PATH}"
107+ # Small delay to ensure systemd detects the removal
108+ sleep 0.1
109+ # Restore from backup (simulating install phase)
110+ cp "${NVIDIA_CTK_PATH}.backup" "${NVIDIA_CTK_PATH}"
111+ # Ensure executable permissions
112+ chmod +x "${NVIDIA_CTK_PATH}"
113+ # Clean up backup
114+ rm -f "${NVIDIA_CTK_PATH}.backup"
115+
116+ # wait for systemd path unit to detect the change and trigger the service
106117 sleep 3
107118
108119 # Check if the file /var/run/cdi/nvidia.yaml is created
You can’t perform that action at this time.
0 commit comments