...

Text file src/edge-infra.dev/cmd/sds/vms/usbredir-launcher/launcher.sh

Documentation: edge-infra.dev/cmd/sds/vms/usbredir-launcher

     1#!/bin/sh
     2
     3DEVICE_IDENTIFIER=""
     4
     5if [ -n "$VID" ] && [ -n "$PID" ]; then
     6    DEVICE_IDENTIFIER="$VID:$PID"
     7elif [ -n "$BUS_ADDRESS" ] && [ -n "$DEVICE_ADDRESS" ]; then
     8    DEVICE_IDENTIFIER="$BUS_ADDRESS-$DEVICE_ADDRESS"
     9else
    10    echo "Required variables not defined"
    11    exit 1
    12fi
    13
    14while true
    15do
    16    if [ -n "$VID" ] && [ -n "$PID" ]; then
    17        device_exists=$(lsusb | grep "ID $DEVICE_IDENTIFIER")
    18    elif [ -n "$BUS_ADDRESS" ] && [ -n "$DEVICE_ADDRESS" ]; then
    19        device_exists=$(lsusb | grep "Bus $BUS_ADDRESS Device $DEVICE_ADDRESS")
    20    fi
    21
    22    if [ -z "$device_exists"  ]; then
    23        echo "Could not find device $DEVICE_IDENTIFIER"
    24        exit 1
    25    fi
    26
    27    /usr/bin/virtctl usbredir "$DEVICE_IDENTIFIER" -n "$NAMESPACE" "$VM"
    28    sleep 10
    29done

View as plain text