#!/bin/sh DEVICE_IDENTIFIER="" if [ -n "$VID" ] && [ -n "$PID" ]; then DEVICE_IDENTIFIER="$VID:$PID" elif [ -n "$BUS_ADDRESS" ] && [ -n "$DEVICE_ADDRESS" ]; then DEVICE_IDENTIFIER="$BUS_ADDRESS-$DEVICE_ADDRESS" else echo "Required variables not defined" exit 1 fi while true do if [ -n "$VID" ] && [ -n "$PID" ]; then device_exists=$(lsusb | grep "ID $DEVICE_IDENTIFIER") elif [ -n "$BUS_ADDRESS" ] && [ -n "$DEVICE_ADDRESS" ]; then device_exists=$(lsusb | grep "Bus $BUS_ADDRESS Device $DEVICE_ADDRESS") fi if [ -z "$device_exists" ]; then echo "Could not find device $DEVICE_IDENTIFIER" exit 1 fi /usr/bin/virtctl usbredir "$DEVICE_IDENTIFIER" -n "$NAMESPACE" "$VM" sleep 10 done