test
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#!/command/with-contenv bashio
|
||||
|
||||
sleep 5s
|
||||
|
||||
if bashio::config.has_value 'autofind'; then
|
||||
autofind=($(bashio::config 'autofind'))
|
||||
bashio::log.info "Set AUTOFIND hub to ${autofind}"
|
||||
@@ -33,7 +31,6 @@ if bashio::config.has_value 'autouse'; then
|
||||
else
|
||||
bashio::log.info "AUTO USE CLEAR ALL"
|
||||
/usr/bin/vhclient -t "AUTO USE CLEAR ALL"
|
||||
#sleep 5s
|
||||
bashio::log.info "STOP USING ALL LOCAL"
|
||||
/usr/bin/vhclient -t "STOP USING ALL LOCAL"
|
||||
fi
|
||||
14
vhclient/rootfs/etc/s6-overlay/s6-rc.d/config-devices/run
Executable file
14
vhclient/rootfs/etc/s6-overlay/s6-rc.d/config-devices/run
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/command/with-contenv bashio
|
||||
|
||||
mapfile -t devices < <(/usr/bin/vh_list_devices)
|
||||
for device in "${devices[@]}"; do
|
||||
options=$(bashio::api.supervisor GET "/addons/self/options/config")
|
||||
if [ -z $(echo $options | jq --arg device "$device" '.usbdevices[] | select(.device == ($device))') ]; then
|
||||
bashio::log.info "Adding to config: ${device}"
|
||||
options_updated=$(echo $options | jq --arg device "$device" '.usbdevices |= . + [{ device: ($device), use: false }]')
|
||||
bashio::log.info "Options updated: ${options_updated}"
|
||||
options_payload=$(echo $options_updated | jq -r '. = { options: . }')
|
||||
bashio::log.info "Payload: ${options_payload}"
|
||||
bashio::api.supervisor POST "/addons/self/options" $(echo $options_updated | jq -r '. = { options: . }')
|
||||
fi
|
||||
done
|
||||
4
vhclient/rootfs/etc/s6-overlay/s6-rc.d/init-config/run
Executable file
4
vhclient/rootfs/etc/s6-overlay/s6-rc.d/init-config/run
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/command/with-contenv bashio
|
||||
|
||||
bashio::log.info "Waiting a bit for vhclient ..."
|
||||
sleep 5s
|
||||
1
vhclient/rootfs/etc/s6-overlay/s6-rc.d/init-config/type
Normal file
1
vhclient/rootfs/etc/s6-overlay/s6-rc.d/init-config/type
Normal file
@@ -0,0 +1 @@
|
||||
oneshot
|
||||
1
vhclient/rootfs/etc/s6-overlay/s6-rc.d/init-config/up
Normal file
1
vhclient/rootfs/etc/s6-overlay/s6-rc.d/init-config/up
Normal file
@@ -0,0 +1 @@
|
||||
/etc/s6-overlay/s6-rc.d/config/run
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/command/with-contenv bashio
|
||||
#set -x
|
||||
|
||||
#test=($(bashio::config 'test'))
|
||||
#test+=('one', 'two')
|
||||
#bashio::config::update 'test' "${test[@]}"
|
||||
#bashio::addon.option 'test' $test[@]
|
||||
|
||||
#TEST
|
||||
#bashio::addon.option 'usbdevices' { 'name': 'one', 'use': false}
|
||||
#my_array=($(bashio::config 'my_array'))
|
||||
#my_array+=('one') # Add a new item to the array
|
||||
#my_array+=({ 'name': 'one', 'use': false}) # Add a new item to the array
|
||||
#bashio::config::update 'my_array' "${my_array[@]}"
|
||||
|
||||
#list1=$(/usr/bin/vhclient -t LIST)
|
||||
#list2=$(eval 'grep "--" <<< "$list1"')
|
||||
#bashio::log.info "${list1}"
|
||||
#bashio::log.info "${list2}"
|
||||
|
||||
#mapfile -t devices < <(/usr/bin/vhclient -t LIST)
|
||||
mapfile -t devices < <(/usr/bin/vh_list_devices)
|
||||
for device in "${devices[@]}"; do
|
||||
#options=$(bashio::addon.options)
|
||||
options=$(bashio::api.supervisor GET "/addons/self/options/config")
|
||||
gurka=$(echo $options | jq --arg device "$device" '.usbdevices[] | select(.device == ($device))')
|
||||
bashio::log.info "Options: ${gurka}"
|
||||
|
||||
#if [[ ! " ${options}.usbdevices[*] " =~ [[:space:]]${device}[[:space:]] ]]; then
|
||||
if [ -z $(echo $options | jq --arg device "$device" '.usbdevices[] | select(.device == ($device))') ]; then
|
||||
|
||||
bashio::log.info "Adding to config: ${device}"
|
||||
|
||||
options_updated=$(echo $options | jq --arg device "$device" '.usbdevices |= . + [{ device: ($device), use: false }]')
|
||||
bashio::log.info "Options updated: ${options_updated}"
|
||||
#payload=$(bashio::var.json options "^${new_options}")
|
||||
#options_payload='{"options": ${options_updated}}'
|
||||
options_payload=$(echo $options_updated | jq -r '. = { options: . }')
|
||||
bashio::log.info "Payload: ${options_payload}"
|
||||
bashio::api.supervisor POST "/addons/self/options" "${options_payload}"
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
#options=$(bashio::addon.options)
|
||||
#new_options=$(echo $options | jq .usbdevices += [{ device: 'ONE', use: false }])
|
||||
#payload=$(bashio::var.json options "^${new_options}")
|
||||
#bashio::api.supervisor POST "/addons/self/options" "${payload}"
|
||||
curl -sH "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/addons/self/info | jq .data.options
|
||||
2
vhclient/rootfs/etc/s6-overlay/s6-rc.d/vhclient-add-devices/run
Executable file
2
vhclient/rootfs/etc/s6-overlay/s6-rc.d/vhclient-add-devices/run
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
bashio::log.info "Adding selected devices"
|
||||
@@ -0,0 +1 @@
|
||||
oneshot
|
||||
Reference in New Issue
Block a user