Created
March 31, 2025 11:24
-
-
Save eira-fransham/21ec4a4b71c5d8e37babe5b83d109578 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#! /bin/bash | |
ilok_details=$(lsusb | grep 'iLok' | grep -P -o '[0-9a-f]+:[0-9a-f]+') | |
for ilok in $ilok_details; do | |
ilok_vendor=$(echo $ilok | grep -P -o '^[0-9a-f]+') | |
ilok_product=$(echo $ilok | grep -P -o '[0-9a-f]+$') | |
ilok_device=$(cat <<-HERE | |
<hostdev mode='subsystem' type='usb' managed='yes'> | |
<source> | |
<vendor id='0x${ilok_vendor}'/> | |
<product id='0x${ilok_product}'/> | |
</source> | |
</hostdev> | |
HERE | |
) | |
virsh attach-device ${1} --file <(echo $ilok_device) --current | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment