summaryrefslogtreecommitdiff
path: root/usr.sbin/fw_update/fw_update.sh
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/fw_update/fw_update.sh')
-rw-r--r--usr.sbin/fw_update/fw_update.sh39
1 files changed, 34 insertions, 5 deletions
diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh
index 2dc1e2cdae5..87af486df23 100644
--- a/usr.sbin/fw_update/fw_update.sh
+++ b/usr.sbin/fw_update/fw_update.sh
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: fw_update.sh,v 1.59 2024/11/04 01:24:00 afresh1 Exp $
+# $OpenBSD: fw_update.sh,v 1.60 2024/11/09 02:19:48 afresh1 Exp $
#
# Copyright (c) 2021,2023 Andrew Hewus Fresh <afresh1@openbsd.org>
#
@@ -490,18 +490,20 @@ unregister_firmware() {
}
usage() {
- echo "usage: ${0##*/} [-adFnv] [-p path] [driver | file ...]"
+ echo "usage: ${0##*/} [-adFlnv] [-p path] [driver | file ...]"
exit 1
}
ALL=false
DOWNLOAD_ONLY=false
-while getopts :adFnp:v name
+LIST=false
+while getopts :adFlnp:v name
do
case "$name" in
a) ALL=true ;;
d) DELETE=true ;;
F) DOWNLOAD_ONLY=true ;;
+ l) LIST=true ;;
n) DRYRUN=true ;;
p) FWURL="$OPTARG" ;;
v) ((++VERBOSE)) ;;
@@ -517,6 +519,9 @@ do
done
shift $((OPTIND - 1))
+# When listing, provide a clean output
+"$LIST" && VERBOSE=1 ENABLE_SPINNER=false
+
# Progress bars, not spinner When VERBOSE > 1
((VERBOSE > 1)) && ENABLE_SPINNER=false
@@ -531,13 +536,13 @@ fi
# "Download only" means local dir and don't install
if "$DOWNLOAD_ONLY"; then
INSTALL=false
- LOCALSRC="${LOCALSRC:-.}"
+ "$LIST" || LOCALSRC="${LOCALSRC:-.}"
elif [ "$LOCALSRC" ]; then
DOWNLOAD=false
fi
if [ -x /usr/bin/id ] && [ "$(/usr/bin/id -u)" != 0 ]; then
- if "$DOWNLOAD_ONLY"; then
+ if "$DOWNLOAD_ONLY" || "$LIST"; then
# When we aren't in the installer,
# allow downloading as the current user.
DROP_PRIVS=false
@@ -602,6 +607,8 @@ if "$DELETE"; then
comma=,
if "$DRYRUN"; then
((VERBOSE)) && echo "Delete $fw"
+ elif "$LIST"; then
+ echo "$fw"
else
delete_firmware "$fw" || {
status " ($fw failed)"
@@ -613,6 +620,9 @@ if "$DELETE"; then
[ "$comma" ] || status none
+ # no status when listing
+ "$LIST" && rm -f "$FD_DIR/status"
+
exit
fi
@@ -640,11 +650,19 @@ set -A update ''
kept=''
unregister=''
+"$LIST" && "$DOWNLOAD_ONLY" &&
+ echo "$FWURL/${CFILE##*/}"
+
if [ "${devices[*]:-}" ]; then
lock_db
for f in "${devices[@]}"; do
d="$( firmware_devicename "$f" )"
+ if "$LIST" && ! "$DOWNLOAD_ONLY"; then
+ echo "$d"
+ continue
+ fi
+
verify_existing=true
if [ "$f" = "$d" ]; then
f=$( firmware_filename "$d" ) || {
@@ -675,6 +693,11 @@ if [ "${devices[*]:-}" ]; then
verify_existing=false
fi
+ if "$LIST"; then
+ echo "$FWURL/$f"
+ continue
+ fi
+
set -A installed
if "$INSTALL"; then
set -A installed -- \
@@ -732,6 +755,12 @@ if [ "${devices[*]:-}" ]; then
done
fi
+if "$LIST"; then
+ # No status when listing
+ rm -f "$FD_DIR/status"
+ exit
+fi
+
if "$INSTALL"; then
status " add "
action=Install