From 45793dadd826bea406664893927fa9f6c841351b Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Thu, 10 Jul 2025 17:38:55 -0700 Subject: [PATCH] change retry logic and document why /dev does not work --- entrypoint.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0111fd6..896a617 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,12 +9,15 @@ if [ "${INPUT_UHUB_CONTROL}" != "false" ]; then fi uhubctl -a off -p "${UHUB_PORT}" -l "${UHUB_LOCATION}" # Off seems to be reflected immediately # Capture the number of hidraw devices with the port off - devs="$(find /dev -maxdepth 1 -name 'hi*' |wc -l)" + # The way docker works, we can't seem to monitor /dev directory + # But a USB device should show up in dmesg log when this happens + #devs="$(find /dev -maxdepth 1 -name 'hi*' |wc -l)" + devs=$(dmesg |grep "usb ${UHUB_LOCATION}.${UHUB_PORT}" |grep -c "New USB device found") uhubctl -a on -p "${UHUB_PORT}" -l "${UHUB_LOCATION}" retries=0 - while [ "$(find /dev -maxdepth 1 -name 'hi*' |wc -l)" = "$devs" ] && [ $retries -lt 10 ]; do + while [ "$(dmesg |grep "usb ${UHUB_LOCATION}.${UHUB_PORT}" |grep -c "New USB device found")" = "$devs" ] && [ $retries -lt 10 ]; do # Generally takes a few seconds to settle in - echo "waiting for device connection ($retries / 10)" + echo "waiting for device connection ($((retries+1)) / 10)" sleep 1 retries=$((retries+1)) done