opensuse leap:
#!/bin/bash
   ### NVIDIA DRIVER ###
    export NVIDIA_DISTRO="DISTRO"
    export NVIDIA_ARCH="ARCH"
    export NVIDIA_VERSION="pci_id 0x1BE1"
    export NVIDIA_CUDA="12"
    export NVIDIA_CUDNN="9"
    export NVIDIA_CONTAINER_TOOLKIT_VERSION="1.17.8-1"
	sudo lspci | grep -i nvidia
    sudo hostnamectl
    sudo gcc --version
    echo "multiversion = provides:multiversion(kernel)scsi_tcp" | sudo tee /etc/zypp/zypp.conf
    sudo zypper install kernel-$ARCH-devel=$(uname -r | sed 's/\-default//')
    sudo zypper addrepo https://developer.download.nvidia.com/compute/cuda/repos/$DISTRO/$ARCH/cuda-$DISTRO.repo
    sudo zypper refresh
	sudo zypper install cuda-drivers 
	# OPTION MULTI KERNEL - for NVIDIA
	sudo zypper install openSUSE-repos-Leap-NVIDIA

   ### NVIDIA CUDA ###
    sudo zypper refresh
    sudo zypper install cuda-toolkit
    bash -c 'echo export PATH="${PATH}:/usr/local/cuda-12.9/bin" >> ~/.bashrc'
    bash -c 'echo export PATH="LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda-12.9/lib64" >> ~/.bashrc'
    #reboot

   ### NVIDIA cuddn ###
    sudo zypper refresh
	sudo zypper install cudnn$NVIDIA_CUDNN-cuda-$NVIDIA_CUDA

   ### NVIDIA CONTAINER_TOOLKIT ###
    sudo zypper ar https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo
    # sudo zypper modifyrepo --enable nvidia-container-toolkit-experimental
    sudo zypper refresh
	sudo zypper --gpg-auto-import-keys install nvidia-container-toolkit-${NVIDIA_CONTAINER_TOOLKIT_VERSION} nvidia-container-toolkit-base-${NVIDIA_CONTAINER_TOOLKIT_VERSION} libnvidia-container-tools-${NVIDIA_CONTAINER_TOOLKIT_VERSION} libnvidia-container1-${NVIDIA_CONTAINER_TOOLKIT_VERSION}
    sudo nvidia-ctk runtime configure --runtime=$CONTAINER_RUNTIME
    sudo systemctl restart $CONTAINER_RUNTIME

ubuntu2404:
   
 #!/bin/bash
  #REPO NVIDIA CUDA+CONTAINER+cuDNN
	wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb |
	sudo dpkg -i cuda-keyring_1.1-1_all.deb
	sudo curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && sudo curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | sudo sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

   #PREPARE
	sudo apt purge *nvidia* *cuda* *cudnn*
	sudo apt autoremove
   #INSTALL NVIDIA
  	sudo apt update
	sudo apt install nvidia-driver-550 -y
	sudo apt update
	sudo apt install cuda-toolkit -y
	sudo apt install zlib1g -y
	sudo apt install nvidia-gds -y
	sudo apt install nvidia-cuda-toolkit -y
	sudo apt-get update
	sudo apt-get install cudnn9-cuda-12 -y
	sudo apt-get install cudnn9-cuda-12-dev -y
	sudo apt update
	sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev -y
	sudo apt update
	sudo apt install nvidia-container-toolkit -y
	sudo nvidia-ctk runtime configure --runtime=docker
	sudo systemctl restart docker

hey i got this bash scripts to setup nvidia driver on hosts but i am bothered of writing them for every os again and then individualise for the driver version regarding the gpu and aalso os version like this dosent work with ubntu 22.04 or 20.04: can you help me making a bash script which is multi os using this os dtection functionor simliar:
# Distro-Erkennung
detect_distro() {
    if [ -f /etc/os-release ]; then
        . /etc/os-release
        DISTRO=$ID
        
        case $DISTRO in
            ubuntu|debian|linuxmint|kali)
                PKG_MANAGER="apt"
                PKG_INSTALL="apt install -y"
                PKG_UPDATE="apt update && apt upgrade -y"
                ;;
            fedora)
                PKG_MANAGER="dnf"
                PKG_INSTALL="dnf install -y"
                PKG_UPDATE="dnf upgrade -y"
                ;;
            opensuse-leap|opensuse-tumbleweed)
                PKG_MANAGER="zypper"
                PKG_INSTALL="zypper --non-interactive install"
                PKG_UPDATE="zypper --non-interactive update"
                ;;
            arch|cachyos)
                PKG_MANAGER="pacman"
                PKG_INSTALL="pacman -S --noconfirm"
                PKG_UPDATE="pacman -Syu --noconfirm"
                ;;
            *)
                echo -e "${RED}Nicht unterstützte Distribution: $DISTRO${NC}"
                exit 1
                ;;
        esac
    else
        echo -e "${RED}Kann Distribution nicht erkennen!${NC}"
        exit 1
    fi
}