recovery-initramfs: improve initramfs retry implementation
This commit improves and simplifies the retry implementation. Signed-off-by: Mike Engel <Mike.Engel@digi.com>
This commit is contained in:
parent
190df56f4e
commit
0bb84fec8b
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# recovery-initramfs-init
|
# recovery-initramfs-init
|
||||||
#
|
#
|
||||||
# Copyright (C) 2016, 2017 by Digi International Inc.
|
# Copyright (C) 2016, 2026 by Digi International Inc.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
# This program is free software; you can redistribute it and/or modify it
|
||||||
|
|
@ -364,29 +364,23 @@ swu_package_path() {
|
||||||
# Check whether the package is local and get the absolute path.
|
# Check whether the package is local and get the absolute path.
|
||||||
if echo "${1}" | grep -qs '^file://'; then
|
if echo "${1}" | grep -qs '^file://'; then
|
||||||
local pkg_name="$(basename ${1})"
|
local pkg_name="$(basename ${1})"
|
||||||
local success=false
|
local MAX_RETRIES="10"
|
||||||
local retries=1
|
|
||||||
local max_retries=10
|
|
||||||
|
|
||||||
while [ $success = false ] && [ $retries -le $max_retries ]; do
|
for _ in $(seq ${MAX_RETRIES}); do
|
||||||
for i in ${UPDATE_MOUNT_DIR} $(echo ${USB_MOUNT_DIR}/*); do
|
for i in ${UPDATE_MOUNT_DIR} $(echo ${USB_MOUNT_DIR}/*); do
|
||||||
echo $i | grep -qs "${USB_MOUNT_DIR}/\*" && continue
|
echo $i | grep -qs "${USB_MOUNT_DIR}/\*" && continue
|
||||||
if [ -f "${i}/${pkg_name}" ]; then
|
if [ -f "${i}/${pkg_name}" ]; then
|
||||||
swu_abspath="${i}/${pkg_name}"
|
swu_abspath="${i}/${pkg_name}"
|
||||||
break
|
break 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
sleep 1
|
||||||
if [ -n "${swu_abspath}" ]; then
|
|
||||||
echo "${swu_abspath}"
|
|
||||||
success=true
|
|
||||||
else
|
|
||||||
sleep 1
|
|
||||||
retries=$(( retries + 1 ))
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
if [ -z "${swu_abspath}" ]; then
|
|
||||||
quit_with_error "Unable to find update package '${pkg_name}' after ${max_retries} retries"
|
if [ -n "${swu_abspath}" ]; then
|
||||||
|
echo "${swu_abspath}"
|
||||||
|
else
|
||||||
|
quit_with_error "Unable to find update package '${pkg_name}' after ${MAX_RETRIES} retries"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "${1}"
|
echo "${1}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue