Skip to content

Instantly share code, notes, and snippets.

@eira-fransham
Created March 31, 2025 11:24
Show Gist options
  • Save eira-fransham/21ec4a4b71c5d8e37babe5b83d109578 to your computer and use it in GitHub Desktop.
Save eira-fransham/21ec4a4b71c5d8e37babe5b83d109578 to your computer and use it in GitHub Desktop.
#! /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