From 4da92371ac28bafd8eb72dce6dd294c610174ae1 Mon Sep 17 00:00:00 2001 From: Hans Karlinius Date: Fri, 6 Jun 2025 14:18:42 +0200 Subject: [PATCH] Update use device on/off --- .../rootfs/etc/s6-overlay/scripts/vhclient-use-devices | 8 +++++++- vhclient/rootfs/usr/bin/vh_server_serial_number | 3 +++ vhclient/rootfs/usr/bin/vh_usb_product_vendor | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 vhclient/rootfs/usr/bin/vh_server_serial_number create mode 100755 vhclient/rootfs/usr/bin/vh_usb_product_vendor diff --git a/vhclient/rootfs/etc/s6-overlay/scripts/vhclient-use-devices b/vhclient/rootfs/etc/s6-overlay/scripts/vhclient-use-devices index 99f9ebe..bdc26c2 100755 --- a/vhclient/rootfs/etc/s6-overlay/scripts/vhclient-use-devices +++ b/vhclient/rootfs/etc/s6-overlay/scripts/vhclient-use-devices @@ -8,7 +8,7 @@ fi autouse=$(bashio::cache.get autouse) if $autouse; then - bashio::log.info "AutoShare enabled, will not use devices from configuration" + bashio::log.info "AutoShare All enabled, will not use devices from configuration" exit 0 fi @@ -21,6 +21,12 @@ if bashio::config.has_value 'usbdevices'; then use=$(echo $usbdevice | jq '. | if .use then true else false end') device=$(echo $usbdevice | jq '.device | tostring') deviceid=$(echo $device | sed 's/.*(\(.*\)).*/\1/g') + + server_serial=$(/usr/bin/vh_server_serial_number ${deviceid%.*}) + device2=$(/usr/bin/vh_usb_product_vendor $deviceid) + deviceid2=$(server_serial.$device2) + bashio::log.info "GURKA-${deviceid2}" + if $use; then bashio::log.info "AUTO USE DEVICE,${deviceid}" /usr/bin/vhclient -t "AUTO USE DEVICE,${deviceid}" diff --git a/vhclient/rootfs/usr/bin/vh_server_serial_number b/vhclient/rootfs/usr/bin/vh_server_serial_number new file mode 100755 index 0000000..96208d3 --- /dev/null +++ b/vhclient/rootfs/usr/bin/vh_server_serial_number @@ -0,0 +1,3 @@ +#!/command/with-contenv bashio + +/usr/bin/vhclient -t "server info,$1" | awk '{ if ($0 ~ /SERIAL NUMBER/) { print $3 } }' diff --git a/vhclient/rootfs/usr/bin/vh_usb_product_vendor b/vhclient/rootfs/usr/bin/vh_usb_product_vendor new file mode 100755 index 0000000..3c04958 --- /dev/null +++ b/vhclient/rootfs/usr/bin/vh_usb_product_vendor @@ -0,0 +1,3 @@ +#!/command/with-contenv bashio + +/usr/bin/vhclient -t "device info,$1" | awk '{ if ($0 ~ /PRODUCT ID/) { p=$3 } if ($0 ~ /VENDOR ID/) { v=$3 } } END { printf("%d.%d",p,v) }'