Update use device on/off
This commit is contained in:
@@ -17,21 +17,15 @@ if bashio::config.has_value 'usbdevices'; then
|
|||||||
usbdevices_json=$(echo $options | jq -c '.usbdevices[]')
|
usbdevices_json=$(echo $options | jq -c '.usbdevices[]')
|
||||||
readarray -t usbdevices < <(echo "$usbdevices_json")
|
readarray -t usbdevices < <(echo "$usbdevices_json")
|
||||||
mapfile -t inuse_devices < <(/usr/bin/vh_list_inuse_devices)
|
mapfile -t inuse_devices < <(/usr/bin/vh_list_inuse_devices)
|
||||||
bashio::log.info "Devices in use - ${inuse_devices[@]}"
|
for inuse_device in "${!inuse_devices[@]}"; do
|
||||||
|
bashio::log.info "Device in use - ${inuse_device}"
|
||||||
|
done
|
||||||
for usbdevice in "${usbdevices[@]}"; do
|
for usbdevice in "${usbdevices[@]}"; do
|
||||||
use=$(echo $usbdevice | jq '. | if .use then true else false end')
|
use=$(echo $usbdevice | jq '. | if .use then true else false end')
|
||||||
device=$(echo $usbdevice | jq '.device | tostring')
|
device=$(echo $usbdevice | jq '.device | tostring')
|
||||||
deviceid=$(echo $device | sed 's/.*(\(.*\)).*/\1/g')
|
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-${inuse_devices[@]}"
|
|
||||||
|
|
||||||
if [[ ${inuse_devices[@]} =~ .*${deviceid}.* ]]; then
|
if [[ ${inuse_devices[@]} =~ .*${deviceid}.* ]]; then
|
||||||
if ! $use; then
|
if ! $use; then
|
||||||
# bashio::log.info "AUTO USE DEVICE,${deviceid} - already in use"
|
|
||||||
# else
|
|
||||||
result=$(/usr/bin/vhclient -t "STOP USING,${deviceid}")
|
result=$(/usr/bin/vhclient -t "STOP USING,${deviceid}")
|
||||||
bashio::log.info "STOP USING,${deviceid} - ${result}"
|
bashio::log.info "STOP USING,${deviceid} - ${result}"
|
||||||
fi
|
fi
|
||||||
@@ -39,23 +33,7 @@ if bashio::config.has_value 'usbdevices'; then
|
|||||||
if $use; then
|
if $use; then
|
||||||
result=$(/usr/bin/vhclient -t "AUTO USE DEVICE,${deviceid}")
|
result=$(/usr/bin/vhclient -t "AUTO USE DEVICE,${deviceid}")
|
||||||
bashio::log.info "AUTO USE DEVICE,${deviceid} - ${result}"
|
bashio::log.info "AUTO USE DEVICE,${deviceid} - ${result}"
|
||||||
# else
|
|
||||||
# bashio::log.info "STOP USING,${deviceid} - not in use"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#if $use; then
|
|
||||||
#bashio::log.info "AUTO USE DEVICE,${deviceid}"
|
|
||||||
#/usr/bin/vhclient -t "AUTO USE DEVICE,${deviceid}"
|
|
||||||
#bashio::log.info "AutoShare ${deviceid2} on"
|
|
||||||
#/usr/bin/vh_editini AutoShare $deviceid2 1
|
|
||||||
#else
|
|
||||||
#if [[ "${inuse_devices[@]}" =~ "$device" ]]; then
|
|
||||||
#bashio::log.info "STOP USING,${deviceid}"
|
|
||||||
#/usr/bin/vhclient -t "STOP USING,${deviceid}"
|
|
||||||
#bashio::log.info "AutoShare ${deviceid2} off"
|
|
||||||
#/usr/bin/vh_editini AutoShare $deviceid2 0
|
|
||||||
#fi
|
|
||||||
#fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/command/with-contenv bashio
|
|
||||||
|
|
||||||
/usr/bin/vhclient -t "server info,$1" | awk '{ if ($0 ~ /SERIAL NUMBER/) { print $3 } }'
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/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) }'
|
|
||||||
Reference in New Issue
Block a user