From 9dc9c4e864e6bc113e7839598247db26bdf63d68 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 17 Jun 2021 10:32:53 +0200 Subject: [PATCH] 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 --- src/opnsense/scripts/firmware/check.sh | 13 +++++++------ .../service/conf/actions.d/actions_firmware.conf | 16 ++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/opnsense/scripts/firmware/check.sh b/src/opnsense/scripts/firmware/check.sh index 573be79a2..97b0ba63c 100755 --- a/src/opnsense/scripts/firmware/check.sh +++ b/src/opnsense/scripts/firmware/check.sh @@ -37,11 +37,12 @@ # upgrade_packages: array with { name: , current_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} diff --git a/src/opnsense/service/conf/actions.d/actions_firmware.conf b/src/opnsense/service/conf/actions.d/actions_firmware.conf index 11aa2c30f..6f86a117b 100644 --- a/src/opnsense/service/conf/actions.d/actions_firmware.conf +++ b/src/opnsense/service/conf/actions.d/actions_firmware.conf @@ -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: