change retry logic and document why /dev does not work
This commit is contained in:
parent
5951fa8088
commit
45793dadd8
1 changed files with 6 additions and 3 deletions
|
@ -9,12 +9,15 @@ if [ "${INPUT_UHUB_CONTROL}" != "false" ]; then
|
||||||
fi
|
fi
|
||||||
uhubctl -a off -p "${UHUB_PORT}" -l "${UHUB_LOCATION}" # Off seems to be reflected immediately
|
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
|
# 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}"
|
uhubctl -a on -p "${UHUB_PORT}" -l "${UHUB_LOCATION}"
|
||||||
retries=0
|
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
|
# 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
|
sleep 1
|
||||||
retries=$((retries+1))
|
retries=$((retries+1))
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Reference in a new issue