From da4675cb4ac2e3efa206ef53ec5fa47719deae1b Mon Sep 17 00:00:00 2001 From: Jos Schellevis Date: Tue, 13 Jan 2015 11:02:07 +0000 Subject: [PATCH] Upgrade for firmware upgrade add check for pkg package and change scripting to allow sinlge package upgrade, also fixes #27 --- src/opnsense/scripts/pkg_upgrade.sh | 21 ++++++++++++++++----- src/www/system_firmware_check.php | 14 +++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/opnsense/scripts/pkg_upgrade.sh b/src/opnsense/scripts/pkg_upgrade.sh index 354bf7678..91d9db94f 100755 --- a/src/opnsense/scripts/pkg_upgrade.sh +++ b/src/opnsense/scripts/pkg_upgrade.sh @@ -24,18 +24,29 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +package=$1 pkg_running=`ps -x | grep "pkg " | grep -v "grep"` if [ "$pkg_running" == "" ]; then if [ -f /tmp/pkg_upgrade.progress ]; then # Remove leftovers from previous upgrade first rm /tmp/pkg_upgrade.progress fi - # start pkg upgrade - echo '***STARTING UPGRADE***' > /tmp/pkg_upgrade.progress - pkg upgrade -y >> /tmp/pkg_upgrade.progress - echo '***DONE***' >> /tmp/pkg_upgrade.progress + if [ "$package" == "all" ]; then + # start pkg upgrade + echo '***STARTING UPGRADE***' > /tmp/pkg_upgrade.progress + pkg upgrade -y >> /tmp/pkg_upgrade.progress + echo '***CHECKING FOR MORE UPGRADES, CAN TAKE 30 SECONDS***' >> /tmp/pkg_upgrade.progress + /usr/local/opnsense/scripts/pkg_updatecheck.sh + echo '***DONE***' >> /tmp/pkg_upgrade.progress + else + # start pkg upgrade + echo '***STARTING UPGRADE - ONE PACKAGE***' > /tmp/pkg_upgrade.progress + pkg upgrade -y $package >> /tmp/pkg_upgrade.progress + echo '***CHECKING FOR MORE UPGRADES, CAN TAKE 30 SECONDS***' >> /tmp/pkg_upgrade.progress + /usr/local/opnsense/scripts/pkg_updatecheck.sh + echo '***DONE***' >> /tmp/pkg_upgrade.progress + fi else echo 'Upgrade already in progress' echo '***DONE***' - /usr/local/opnsense/scripts/pkg_updatecheck.sh fi diff --git a/src/www/system_firmware_check.php b/src/www/system_firmware_check.php index f4a87add6..84992ac06 100644 --- a/src/www/system_firmware_check.php +++ b/src/www/system_firmware_check.php @@ -36,6 +36,7 @@ require_once("script/load_phalcon.php"); $file_pkg_status="/tmp/pkg_status.json"; $file_upgrade_progress="/tmp/pkg_upgrade.progress"; +$pkgonly=false; $pkg_status = array(); @@ -52,7 +53,11 @@ if($_POST['action'] == 'pkg_upgrade') { $shell_output = array(); $shell = new OPNsense\Core\Shell(); // execute shell command and collect (only valid) info into named array - $shell->exec("/usr/local/opnsense/scripts/pkg_upgrade.sh > /dev/null 2 > /dev/null < /dev/null &",false,false,$shell_output); + if ( $pkgonly == true ) { + $shell->exec("/usr/local/opnsense/scripts/pkg_upgrade.sh pkg > /dev/null 2 > /dev/null < /dev/null &",false,false,$shell_output); + } else { + $shell->exec("/usr/local/opnsense/scripts/pkg_upgrade.sh all > /dev/null 2 > /dev/null < /dev/null &",false,false,$shell_output); + } } if($_POST['action'] == 'update_status' ) { @@ -78,6 +83,13 @@ if($_REQUEST['getupdatestatus']) { echo "".gettext("Repository Problem")."
".gettext("Click to retry now").""; } elseif ($pkg_status["updates"]=="0") { echo "".gettext("At")." ".$pkg_status["last_check"]."".gettext(" no updates found.")."
".gettext("Click to check now").""; + } elseif ( $pkg_status["updates"] == 1 && $pkg_status["upgrade_packages"][0]["name"] == "pkg" ) { + echo "".gettext("There is a mandatory update for the package manager."). + "(When last checked at: ".$pkg_status["last_check"]." )
". + "".gettext("Upgrade pkg and recheck, there maybe other updates available."). + "
".gettext("Upgrade Now"). + " ".gettext("Re-Check Now").""; + $pkgonly=true; } else { echo "".gettext("A total of ").$pkg_status["updates"].gettext(" update(s) are available.")."(When last checked at: ".$pkg_status["last_check"]." )"."
".gettext("Upgrade Now")." ".gettext("Re-Check Now").""; }