firmware: add backend glue to support install probing of plugins #5037

Allows to list dependencies as well.  Remove the JSON return, best to
use something as follows now:

    # configctl firmware probe && configctl firmware product
This commit is contained in:
Franco Fichtner 2021-06-17 10:32:53 +02:00
parent e15c2d6f4a
commit 9dc9c4e864
2 changed files with 15 additions and 14 deletions

View File

@ -37,11 +37,12 @@
# upgrade_packages: array with { name: <package_name>, current_version: <current_version>, new_version: <new_version> }
JSONFILE="/tmp/pkg_upgrade.json"
JSONRETURN=${1}
LOCKFILE="/tmp/pkg_upgrade.progress"
OUTFILE="/tmp/pkg_update.out"
TEE="/usr/bin/tee -a"
CUSTOMPKG=${1}
rm -f ${JSONFILE}
: > ${LOCKFILE}
@ -123,7 +124,9 @@ else
# now check what happens when we would go ahead
(pkg upgrade -Un 2>&1) | ${TEE} ${LOCKFILE} ${OUTFILE}
if [ "${product_id}" != "${product_target}" ]; then
if [ -n "${CUSTOMPKG}" ]; then
(pkg install -Un "${CUSTOMPKG}" 2>&1) | ${TEE} ${LOCKFILE} ${OUTFILE}
elif [ "${product_id}" != "${product_target}" ]; then
(pkg install -r ${product_repo} -Un "${product_target}" 2>&1) | ${TEE} ${LOCKFILE} ${OUTFILE}
elif [ -z "$(pkg rquery %n ${product_id})" ]; then
# although this should say "to update matching" we emulate for check below as pkg does not catch this
@ -133,6 +136,8 @@ else
# Check for additional repository errors
if grep -q 'Unable to update repository' ${OUTFILE}; then
repository="error" # already set but reset here for clarity
elif [ -n "${CUSTOMPKG}" ] && grep -q "No packages available to install matching..${CUSTOMPKG}" ${OUTFILE}; then
repository="incomplete"
elif grep -q "No packages available to install matching..${product_target}" ${OUTFILE}; then
repository="incomplete"
else
@ -368,8 +373,4 @@ cat > ${JSONFILE} << EOF
}
EOF
if [ -n "${JSONRETURN}" ]; then
cat ${JSONFILE}
fi
echo '***DONE***' >> ${LOCKFILE}

View File

@ -1,22 +1,22 @@
[check]
command:daemon -f /usr/local/opnsense/scripts/firmware/launcher.sh check
parameters:
parameters:%s
type:script
message:Retrieve firmware update status
[probe]
command:/usr/local/opnsense/scripts/firmware/launcher.sh check
parameters:%s
type:script
message:Running firmware update status
description:Firmware update check
[flush]
command:rm -f /tmp/pkg_upgrade.json
parameters:
type:script
message:Flush firmware update status
[probe]
command:/usr/local/opnsense/scripts/firmware/launcher.sh check
parameters:
type:script
message:Running firmware update status
description:Firmware update check
[changelog.fetch]
command: /usr/local/opnsense/scripts/firmware/changelog.sh fetch
parameters: