Limit the number USB devices used by each client?

Hi, I have 20 computer clients to connect 10 shared USB devices. Each USB device allow only 1 connection at any time. And we don't want any computer connecting to more than 1 shared USB device. So ideally 10 computers can use these 10 shared USB devices simultaneously. If the USB device is not in use, it should be put back to available pool for next user. As we also have other computers in same LAN, we need to prevent shared USB devices from being connected by other computers as well.

Do we have to use different configuration file in each computer client?

I have read the configurations of virtualhere but still not sure about something (especially how to limit the number USB devices used by each client). Would you please advise?

Thanks.

#2

Actually this is quite easy to do, follow this https://www.virtualhere.com/authorization

You can pass an argument called $NUM_BINDINGS$. So you just need to have a very simple script that just returns not authorized if num_bindings = 1 e.g

In the server config.ini file
---------------------------------
...
clientAuthorization=/root/auth.sh "$NUM_BINDINGS$"
...

In the auth.sh file
----------------------

#!/bin/sh
# Return 1 if the user is allowed to access this device
# Return 0 if the user is not allowed to access this device
# $1 = $NUM_BINDINGS$

if [ "$1" -eq "1" ]; then
  exit 0
else
  exit 1
fi
#3

Thank you Michael. Would you please advise what script shall I use in Windows batch?
I have tried this in server config.ini
--------------------------------------
clientAuthorization=.\auth.bat %NUM_BINDINGS%

in the auth.bat file
-------------------------
@echo off
IF %1 == 1 (EXIT 0) ELSE (EXIT 1)

also tried in the auto.bat file
---------------------
@echo off
IF %1 == 1 (ECHO 0) ELSE (ECHO 1)

Still couldn't get it work. it didn't allow anyone to connect when using ECHO. and allow unlimited connection when using EXIT.

#4

OK if its windows you do it like this:

config.ini line

ClientAuthorization=c:\Users\Michael\Downloads\auth.bat $NUM_BINDINGS$

auth.bat

IF "%1" == "0" (
  EXIT 1
) 
ELSE 
(
  EXIT 0
)