Created
November 5, 2018 08:14
-
-
Save rokups/8f04e8a3389d1b0f6433fc79e72a4896 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
if [ "$EUID" != "0" ]; | |
then | |
echo "Please run as root." | |
exit | |
fi | |
driver="$1" | |
shift | |
while [[ $# > 0 ]]; | |
do | |
dev="0000:$1" | |
shift | |
if [ -z $driver ] | [ -z $dev ]; | |
then | |
exit 1 | |
fi | |
vendor=$(cat /sys/bus/pci/devices/${dev}/vendor) | |
device=$(cat /sys/bus/pci/devices/${dev}/device) | |
echo -n Unbinding $vendor:$device ... | |
if [ -e /sys/bus/pci/devices/${dev}/driver ]; then | |
echo ${dev} > /sys/bus/pci/devices/${dev}/driver/unbind | |
while [ -e /sys/bus/pci/devices/${dev}/driver ]; do | |
sleep 0.5 | |
echo -n . | |
done | |
fi | |
echo " OK!" | |
echo -n Binding \'$driver\' to $vendor:$device ... | |
echo ${vendor} ${device} > /sys/bus/pci/drivers/${driver}/new_id | |
echo " OK!" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment