30 lines
948 B
Plaintext
Executable File
30 lines
948 B
Plaintext
Executable File
#!/usr/bin/with-contenv bashio
|
|
|
|
#set -x
|
|
|
|
bashio::log.info "Adding selected devices"
|
|
|
|
if bashio::config.has_value 'usbdevices'; then
|
|
#usbdevices=($(bashio::config 'usbdevices'))
|
|
#bashio::log.info "Devices: ${usbdevices}"
|
|
options=$(bashio::api.supervisor GET "/addons/self/options/config")
|
|
bashio::log.info "Options: ${options}"
|
|
usbdevices_json=$(echo $options | jq -c '.usbdevices[]')
|
|
readarray -t usbdevices < <(echo "$usbdevices_json")
|
|
bashio::log.info "Devices: ${usbdevices[@]}"
|
|
for usbdevice in "${usbdevices[@]}"; do
|
|
use=$(echo $usbdevice | jq '. | if .use then true else false end')
|
|
device=$(echo $usbdevice | jq '.device | tostring')
|
|
deviceid=$(echo $device | sed 's/.*(\(.*\))/\1/g')
|
|
bashio::log.info "Use: ${use}"
|
|
if $use; then
|
|
bashio::log.info "Set AUTO USE DEVICE for ${deviceid}"
|
|
else
|
|
bashio::log.info "Set STOP USING for ${deviceid}"
|
|
fi
|
|
|
|
# sed 's/.*(\(.*\))/\1/g'
|
|
|
|
done
|
|
fi
|