#!/bin/bash # Copyright 2025 Christoph Willing, Sydney Australia # All rights reserved # If an nvidia module has been installed for a previous kernel version, # update the nvidia kernel module for the new kernel. # # Requires: dkms [ -z $KERNEL_VERSION ] && { echo " No KERNEL_VERSION provided. Exiting now." exit } echo "Checking status of nvidia kernel module ..." if [ -x /usr/sbin/dkms ]; then # Find existing nvidia module NVIDIA_MODULE=$(dkms status |grep nvidia |tail -1|cut -d',' -f1) # If there is a previously installed nvidia module if [ x"$NVIDIA_MODULE" = "x" ]; then echo "No DKMS installed Nvidia kernel module found." else echo " Found NVIDIA_MODULE = $NVIDIA_MODULE" # Is it already installed for this kernel version? if [ "$(dkms status -m nvidia -k $KERNEL_VERSION |cut -d' ' -f 4)" = "installed" ]; then # Nothing to do echo " Module $NVIDIA_MODULE is already installed for kernel $KERNEL_VERSION" else # Update Nvidia kernel module for new kernel version echo " Installing NVIDIA_MODULE $NVIDIA_MODULE for kernel version $KERNEL_VERSION" dkms install $NVIDIA_MODULE -k $KERNEL_VERSION fi fi fi