From 15fbeec36776307ff62f5624fec465ba654feecd Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 20 Feb 2020 19:50:12 +0100 Subject: [PATCH] firmware: good-will nit-picking and some more work to do --- plist | 1 + .../OPNsense/Core/Api/FirmwareController.php | 2 +- src/opnsense/scripts/firmware/launcher.sh | 2 +- .../scripts/firmware/{confplugins.sh => sync.sh} | 12 ++++++++---- .../service/conf/actions.d/actions_firmware.conf | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) rename src/opnsense/scripts/firmware/{confplugins.sh => sync.sh} (77%) diff --git a/plist b/plist index b7d9cd5dd..e62645c7b 100644 --- a/plist +++ b/plist @@ -606,6 +606,7 @@ /usr/local/opnsense/scripts/firmware/running.sh /usr/local/opnsense/scripts/firmware/security.sh /usr/local/opnsense/scripts/firmware/sets.sh +/usr/local/opnsense/scripts/firmware/sync.sh /usr/local/opnsense/scripts/firmware/type.sh /usr/local/opnsense/scripts/firmware/unlock.sh /usr/local/opnsense/scripts/firmware/upgrade.sh diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php index aac343231..4cccb2d6a 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php @@ -548,7 +548,7 @@ class FirmwareController extends ApiControllerBase $response = array(); if ($this->request->isPost()) { - $response['status'] = strtolower(trim($backend->configdRun('firmware confplugins'))); + $response['status'] = strtolower(trim($backend->configdRun('firmware sync'))); } else { $response['status'] = 'failure'; } diff --git a/src/opnsense/scripts/firmware/launcher.sh b/src/opnsense/scripts/firmware/launcher.sh index ce1884c2c..d510597fd 100755 --- a/src/opnsense/scripts/firmware/launcher.sh +++ b/src/opnsense/scripts/firmware/launcher.sh @@ -35,10 +35,10 @@ lock reinstall remove security +sync type unlock upgrade -confplugins " SELECTED=${1} diff --git a/src/opnsense/scripts/firmware/confplugins.sh b/src/opnsense/scripts/firmware/sync.sh similarity index 77% rename from src/opnsense/scripts/firmware/confplugins.sh rename to src/opnsense/scripts/firmware/sync.sh index 22fff9589..c3e640aee 100755 --- a/src/opnsense/scripts/firmware/confplugins.sh +++ b/src/opnsense/scripts/firmware/sync.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (C) 2020 Deciso B.V. -# Copyright (C) 2015-2017 Franco Fichtner +# Copyright (C) 2015-2020 Franco Fichtner # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -26,12 +26,16 @@ # POSSIBILITY OF SUCH DAMAGE. PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress -PACKAGES=`/usr/local/sbin/pluginctl -g system.firmware.plugins | /usr/bin/sed 's/,/ /g'` +# XXX the issue here is we do get all plugins, but some are already installed +PACKAGES=$(/usr/local/sbin/pluginctl -g system.firmware.plugins | /usr/bin/sed 's/,/ /g') # Truncate upgrade progress file : > ${PKG_PROGRESS_FILE} -echo "***GOT REQUEST TO INSTALL: $PACKAGES***" >> ${PKG_PROGRESS_FILE} -pkg install -y $PACKAGES >> ${PKG_PROGRESS_FILE} 2>&1 +echo "***GOT REQUEST TO SYNC: ${PACKAGES}***" >> ${PKG_PROGRESS_FILE} +for PACKAGE in ${PACKAGES}; do + # XXX check which we really need to sync :) + pkg install -y ${PACKAGE} >> ${PKG_PROGRESS_FILE} 2>&1 +done pkg autoremove -y >> ${PKG_PROGRESS_FILE} 2>&1 echo '***DONE***' >> ${PKG_PROGRESS_FILE} diff --git a/src/opnsense/service/conf/actions.d/actions_firmware.conf b/src/opnsense/service/conf/actions.d/actions_firmware.conf index 7fd360d61..651782dcd 100644 --- a/src/opnsense/service/conf/actions.d/actions_firmware.conf +++ b/src/opnsense/service/conf/actions.d/actions_firmware.conf @@ -107,8 +107,8 @@ parameters:%s type:script_output message:Tested for presence of plugin %s -[confplugins] -command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/firmware/launcher.sh confplugins +[sync] +command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/firmware/launcher.sh sync parameters: type:script message: install missing configured plugins