test
This commit is contained in:
35
vhclient/rootfs/etc/s6-overlay/scripts/config-client
Executable file
35
vhclient/rootfs/etc/s6-overlay/scripts/config-client
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/command/with-contenv bashio
|
||||
|
||||
options=$(bashio::api.supervisor GET "/addons/self/options/config")
|
||||
#autofind=$(echo $options | jq '. | if .autofind then true else false end')
|
||||
autouse=$(echo $options | jq '. | if .autouse then true else false end')
|
||||
|
||||
#if $autofind; then
|
||||
# bashio::log.info "Enable AutoFind"
|
||||
# /usr/bin/vh_edit_config General AutoFind 1
|
||||
#else
|
||||
# bashio::log.info "Disable AutoFind"
|
||||
# /usr/bin/vh_edit_config General AutoFind 0
|
||||
#fi
|
||||
|
||||
if $autouse; then
|
||||
bashio::log.info "AUTO USE ALL"
|
||||
/usr/bin/vhclient -t "AUTO USE ALL"
|
||||
else
|
||||
bashio::log.info "AUTO USE CLEAR ALL"
|
||||
/usr/bin/vhclient -t "AUTO USE CLEAR ALL"
|
||||
bashio::log.info "STOP USING ALL LOCAL"
|
||||
/usr/bin/vhclient -t "STOP USING ALL LOCAL"
|
||||
fi
|
||||
|
||||
#if bashio::config.has_value 'clientid'; then
|
||||
# clientid=($(bashio::config 'clientid'))
|
||||
# bashio::log.info "Set ClientId to ${clientid}"
|
||||
# /usr/bin/vh_edit_config General ClientId ${clientid}
|
||||
#fi
|
||||
|
||||
if bashio::config.has_value 'manualhub'; then
|
||||
manualhub=($(bashio::config 'manualhub'))
|
||||
bashio::log.info "MANUAL HUB ADD,${manualhub}"
|
||||
/usr/bin/vhclient -t "MANUAL HUB ADD,${manualhub}"
|
||||
fi
|
||||
14
vhclient/rootfs/etc/s6-overlay/scripts/config-devices
Executable file
14
vhclient/rootfs/etc/s6-overlay/scripts/config-devices
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/command/with-contenv bashio
|
||||
#set -x
|
||||
|
||||
mapfile -t devices < <(/usr/bin/vh_list_devices)
|
||||
for device in "${devices[@]}"; do
|
||||
options=$(bashio::api.supervisor GET "/addons/self/options/config")
|
||||
options_usbdevices_device=$(echo $options | jq --arg device "$device" '.usbdevices[] | select(.device == ($device))')
|
||||
if [ -z "$options_usbdevices_device" ]; then
|
||||
bashio::log.info "Adding to config: ${device}"
|
||||
options_updated=$(echo $options | jq --arg device "$device" '.usbdevices |= . + [{ device: ($device), use: false }]')
|
||||
options_payload=$(echo $options_updated | jq -r '. = { options: . }')
|
||||
bashio::api.supervisor POST "/addons/self/options" "${options_payload}"
|
||||
fi
|
||||
done
|
||||
18
vhclient/rootfs/etc/s6-overlay/scripts/init-config
Executable file
18
vhclient/rootfs/etc/s6-overlay/scripts/init-config
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/command/with-contenv bashio
|
||||
|
||||
options=$(bashio::api.supervisor GET "/addons/self/options/config")
|
||||
autofind=$(echo $options | jq '. | if .autofind then true else false end')
|
||||
|
||||
if $autofind; then
|
||||
bashio::log.info "Enable AutoFind"
|
||||
/usr/bin/vh_edit_config General AutoFind 1
|
||||
else
|
||||
bashio::log.info "Disable AutoFind"
|
||||
/usr/bin/vh_edit_config General AutoFind 0
|
||||
fi
|
||||
|
||||
if bashio::config.has_value 'clientid'; then
|
||||
clientid=($(bashio::config 'clientid'))
|
||||
bashio::log.info "Set ClientId to ${clientid}"
|
||||
/usr/bin/vh_edit_config General ClientId ${clientid}
|
||||
fi
|
||||
4
vhclient/rootfs/etc/s6-overlay/scripts/init-vhclient
Executable file
4
vhclient/rootfs/etc/s6-overlay/scripts/init-vhclient
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/command/with-contenv bashio
|
||||
|
||||
/sbin/modprobe -s vhci-hcd
|
||||
mount -o remount -t sysfs sysfs /sys
|
||||
22
vhclient/rootfs/etc/s6-overlay/scripts/vhclient-add-devices
Executable file
22
vhclient/rootfs/etc/s6-overlay/scripts/vhclient-add-devices
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
if bashio::config.has_value 'usbdevices'; then
|
||||
options=$(bashio::api.supervisor GET "/addons/self/options/config")
|
||||
usbdevices_json=$(echo $options | jq -c '.usbdevices[]')
|
||||
readarray -t usbdevices < <(echo "$usbdevices_json")
|
||||
mapfile -t inuse_devices < <(/usr/bin/vh_list_inuse_devices)
|
||||
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')
|
||||
if $use; then
|
||||
bashio::log.info "USE,${deviceid}"
|
||||
/usr/bin/vhclient -t "USE,${deviceid}"
|
||||
else
|
||||
if [[ "${inuse_devices[@]}" =~ "$device" ]]; then
|
||||
bashio::log.info "STOP USING,${deviceid}"
|
||||
/usr/bin/vhclient -t "STOP USING,${deviceid}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user