version 1.143, 2022/01/07 01:47:24 |
version 1.144, 2022/01/07 02:16:31 |
|
|
DRYRUN=false |
DRYRUN=false |
VERBOSE=0 |
VERBOSE=0 |
DELETE=false |
DELETE=false |
DOWNLOAD= |
DOWNLOAD=true |
INSTALL=true |
INSTALL=true |
LOCALSRC= |
LOCALSRC= |
|
|
|
|
fi |
fi |
} |
} |
|
|
|
fetch_cfile() { |
|
if "$DOWNLOAD"; then |
|
set +o noclobber # we want to get the latest CFILE |
|
fetch "$CFILE" || return 1 |
|
set -o noclobber |
|
! signify -qVep "$FWPUB_KEY" -x "$CFILE" -m "$CFILE" && |
|
echo "Signature check of SHA256.sig failed" >&2 && return 1 |
|
elif [ ! -e "$CFILE" ]; then |
|
echo "${0##*/}: $CFILE: No such file or directory" >&2 |
|
return 2 |
|
fi |
|
} |
|
|
verify() { |
verify() { |
|
[ -e "$CFILE" ] || fetch_cfile |
# On the installer we don't get sha256 -C, so fake it. |
# On the installer we don't get sha256 -C, so fake it. |
if ! fgrep -qx "SHA256 (${1##*/}) = $( /bin/sha256 -qb "$1" )" "$CFILE"; then |
if ! fgrep -qx "SHA256 (${1##*/}) = $( /bin/sha256 -qb "$1" )" "$CFILE"; then |
echo "Checksum test for ${1##*/} failed." >&2 |
echo "Checksum test for ${1##*/} failed." >&2 |
|
|
|
|
firmware_filename() { |
firmware_filename() { |
local _f |
local _f |
|
[ -e "$CFILE" ] || fetch_cfile |
_f="$( sed -n "s/.*(\($1-firmware-.*\.tgz\)).*/\1/p" "$CFILE" | sed '$!d' )" |
_f="$( sed -n "s/.*(\($1-firmware-.*\.tgz\)).*/\1/p" "$CFILE" | sed '$!d' )" |
! [ "$_f" ] && echo "Unable to find firmware for $1" >&2 && return 1 |
! [ "$_f" ] && echo "Unable to find firmware for $1" >&2 && return 1 |
echo "$_f" |
echo "$_f" |
|
|
|
|
# "Download only" means local dir and don't install |
# "Download only" means local dir and don't install |
if [ "$OPT_F" ]; then |
if [ "$OPT_F" ]; then |
DOWNLOAD=true |
|
INSTALL=false |
INSTALL=false |
LOCALSRC="${LOCALSRC:-.}" |
LOCALSRC="${LOCALSRC:-.}" |
|
|
|
# Always check for latest CFILE and so latest firmware |
|
if [ -e "$LOCALSRC/$CFILE" ]; then |
|
mv "$LOCALSRC/$CFILE" "$LOCALSRC/$CFILE-OLD" |
|
if fetch_cfile; then |
|
rm -f "$LOCALSRC/$CFILE-OLD" |
|
else |
|
mv "$LOCALSRC/$CFILE-OLD" "$LOCALSRC/$CFILE" |
|
echo "Using existing $CFILE" >&2 |
|
fi |
|
fi |
elif [ "$LOCALSRC" ]; then |
elif [ "$LOCALSRC" ]; then |
DOWNLOAD=false |
DOWNLOAD=false |
fi |
fi |
|
|
REMOVE_LOCALSRC=true |
REMOVE_LOCALSRC=true |
fi |
fi |
|
|
|
CFILE="$LOCALSRC/$CFILE" |
|
|
if [ "${devices[*]:-}" ]; then |
if [ "${devices[*]:-}" ]; then |
"$ALL" && usage 22 |
"$ALL" && usage 22 |
else |
else |
|
|
fi |
fi |
|
|
[ "${devices[*]:-}" ] || exit |
[ "${devices[*]:-}" ] || exit |
|
|
# Only need the CFILE to verify what has been downloaded |
|
# or to convert a device to a filename. |
|
NEED_CFILE="${DOWNLOAD:-false}" |
|
if ! "$NEED_CFILE"; then |
|
for f in "${devices[@]}"; do |
|
if [ "$( firmware_devicename "$f" )" = "$f" ]; then |
|
NEED_CFILE=true |
|
break |
|
fi |
|
done |
|
fi |
|
|
|
# Only need to download if we already decided we did, |
|
# or the same decision as if we NEED_CFILE. |
|
DOWNLOAD="${DOWNLOAD:-$NEED_CFILE}" |
|
|
|
if "$NEED_CFILE"; then |
|
CFILE="$LOCALSRC/$CFILE" |
|
|
|
if "$DOWNLOAD"; then |
|
set +o noclobber # we want to get the latest CFILE |
|
fetch "$CFILE" |
|
set -o noclobber |
|
! signify -qVep "$FWPUB_KEY" -x "$CFILE" -m "$CFILE" && |
|
echo "Signature check of SHA256.sig failed" >&2 && exit 1 |
|
elif [ ! -e "$CFILE" ]; then |
|
echo "${0##*/}: $CFILE: No such file or directory" >&2 |
|
exit 2 |
|
fi |
|
fi |
|
|
|
added='' |
added='' |
updated='' |
updated='' |