#!/bin/sh # SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. " echo "Example: ${0##*/} --i-like-danger 0000:00:1b.0" echo "Warning: Strongly discouraged to reattach PCI devices to dom0" echo "Warning: especially if it doesn't support resetting!" exit 1 } case "${1-}" in --i-like-danger) ;; *) usage;; esac case "${2-}" in "") usage;; *) device="${2}" esac uid="$(id -u)" test "${uid}" = "0" || exec sudo "${0}" echo "${device}" | tee /sys/bus/pci/drivers/pciback/unbind modalias="$(cat "/sys/bus/pci/devices/${device}/modalias")" module="$(modprobe -R "${modalias}" | head -n 1)" echo "${device}" | tee "/sys/bus/pci/drivers/${module}/bind"