This commit is contained in:
Hans Karlinius
2024-12-01 05:35:08 +01:00
parent e56df7db03
commit a077be3c4c
8 changed files with 32 additions and 29 deletions
+4 -4
View File
@@ -2,11 +2,11 @@ ARG BUILD_FROM
FROM $BUILD_FROM FROM $BUILD_FROM
# Install requirements for add-on # Install requirements for add-on
RUN \ #RUN \
apk add --no-cache \ # apk add --no-cache \
nginx # nginx
WORKDIR /data #WORKDIR /data
# Copy root filesystem # Copy root filesystem
COPY rootfs / COPY rootfs /
+1 -1
View File
@@ -1,5 +1,5 @@
name: VirtualHere Client name: VirtualHere Client
version: "0.1.314" version: "0.1.315"
slug: vhclient slug: vhclient
description: VirtualHere Client description: VirtualHere Client
arch: arch:
@@ -1,14 +1,8 @@
#!/command/with-contenv bashio #!/command/with-contenv bashio
if bashio::config.has_value 'autofind'; then options=$(bashio::api.supervisor GET "/addons/self/options/config")
autofind=($(bashio::config 'autofind')) autofind=$(echo $options | jq '. | if .autofind then true else false end')
bashio::log.info "Set AUTOFIND hub to ${autofind}" autouse=$(echo $options | jq '. | if .autouse then true else false end')
if [ "${autofind}" = "true" ]; then
/usr/bin/vh_edit_config General AutoFind 1
else
/usr/bin/vh_edit_config General AutoFind 0
fi
fi
if bashio::config.has_value 'clientid'; then if bashio::config.has_value 'clientid'; then
clientid=($(bashio::config 'clientid')) clientid=($(bashio::config 'clientid'))
@@ -22,9 +16,21 @@ if bashio::config.has_value 'manualhub'; then
/usr/bin/vhclient -t "MANUAL HUB ADD,${manualhub}" /usr/bin/vhclient -t "MANUAL HUB ADD,${manualhub}"
fi fi
if bashio::config.has_value 'autouse'; then #if bashio::config.has_value 'autofind'; then
autouse=($(bashio::config 'autouse')) #autofind=($(bashio::config 'autofind'))
if [ "${autouse}" = "true" ]; then bashio::log.info "Set AUTOFIND hub to ${autofind}"
#if [ "${autofind}" = "true" ]; then
if $autofind; then
/usr/bin/vh_edit_config General AutoFind 1
else
/usr/bin/vh_edit_config General AutoFind 0
fi
#fi
#if bashio::config.has_value 'autouse'; then
#autouse=($(bashio::config 'autouse'))
#if [ "${autouse}" = "true" ]; then
if $autouse; then
bashio::log.info "AUTO USE ALL" bashio::log.info "AUTO USE ALL"
/usr/bin/vhclient -t "AUTO USE ALL" /usr/bin/vhclient -t "AUTO USE ALL"
else else
@@ -33,4 +39,4 @@ if bashio::config.has_value 'autouse'; then
bashio::log.info "STOP USING ALL LOCAL" bashio::log.info "STOP USING ALL LOCAL"
/usr/bin/vhclient -t "STOP USING ALL LOCAL" /usr/bin/vhclient -t "STOP USING ALL LOCAL"
fi fi
fi #fi
@@ -1,3 +0,0 @@
#!/usr/bin/with-contenv bashio
bashio::log.info "Starting VirtualHere HTTP"
exec nginx -c /etc/nginx/vhclient.conf
@@ -1 +0,0 @@
longrun
@@ -1 +0,0 @@
/etc/s6-overlay/s6-rc.d/http/run
@@ -8,24 +8,26 @@ if bashio::config.has_value 'usbdevices'; then
#usbdevices=($(bashio::config 'usbdevices')) #usbdevices=($(bashio::config 'usbdevices'))
#bashio::log.info "Devices: ${usbdevices}" #bashio::log.info "Devices: ${usbdevices}"
options=$(bashio::api.supervisor GET "/addons/self/options/config") options=$(bashio::api.supervisor GET "/addons/self/options/config")
bashio::log.info "Options: ${options}" #bashio::log.info "Options: ${options}"
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")
bashio::log.info "Devices: ${usbdevices[@]}" #bashio::log.info "Devices: ${usbdevices[@]}"
mapfile -t inuse_devices < <(/usr/bin/vh_list_inuse_devices) mapfile -t inuse_devices < <(/usr/bin/vh_list_inuse_devices)
bashio::log.info "Inuse devices: ${inuse_devices[@]}" #bashio::log.info "Inuse devices: ${inuse_devices[@]}"
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')
#bashio::log.info "Use: ${use} Device: ${device} Deviceid: ${deviceid}" #bashio::log.info "Use: ${use} Device: ${device} Deviceid: ${deviceid}"
if $use; then if $use; then
bashio::log.info "AUTO USE DEVICE,${deviceid}" #bashio::log.info "AUTO USE DEVICE,${deviceid}"
/usr/bin/vhclient -t "AUTO USE DEVICE,${deviceid}" #/usr/bin/vhclient -t "AUTO USE DEVICE,${deviceid}"
bashio::log.info "USE,${deviceid}"
/usr/bin/vhclient -t "USE,${deviceid}"
else else
if [[ "${inuse_devices[@]}" =~ "$device" ]]; then if [[ "${inuse_devices[@]}" =~ "$device" ]]; then
bashio::log.info "STOP USING,${deviceid}" bashio::log.info "STOP USING,${deviceid}"
#/usr/bin/vhclient -t "STOP USING,${deviceid}" /usr/bin/vhclient -t "STOP USING,${deviceid}"
fi fi
fi fi
done done