Commit 219f740c authored by Franco Fichtner's avatar Franco Fichtner

firmware: steps towards package actions

o Adds a reinstall backend call
o Moves pkg_upgrade.sh into its own dir
o Don't clobber progress output when action is running
o Rename action to clearly reflect it's purpose
o Tweak EOL message a bit more

This is a test of how far we can go with our backend restructuring
without glitching firmware update temporarily.

(cherry picked from commit a5c4d51d)
parent cb3f42f9
......@@ -5,10 +5,10 @@ upgrade to the new 16.1 series is seamless, except for the following
points:</p>
<p><ul><li>The FreeBSD version changes from 10.1 to 10.2, mainly for driver
updates and general sanity. <strong>If you're running Hyper-V, your installed
disk will change from <em>/dev/ada0</em> to <em>/dev/da0</em> and the system
disk may change from <em>/dev/ada0</em> to <em>/dev/da0</em> and the system
will not boot as a consequence</strong>. You can fix this by manually editing
<em>/etc/fstab</em>. A reinstall using the import configuration and quick/easy
install will work just as well.</li>
<em>/etc/fstab</em> before performing the major upgrade. A reinstall using the
import configuration and quick/easy install will work just as well.</li>
<li>The captive portal implementation has been completely rewritten.
<strong>Your old setup won't be converted and thus will not come back
up</strong>. Reconfiguring the captive portal, however, will be relatively
......
......@@ -122,20 +122,19 @@ class FirmwareController extends ApiControllerBase
public function upgradestatusAction()
{
$backend = new Backend();
$result = array("status"=>"running");
$cmd_result = trim($backend->configdRun("firmware upgrade_status"));
$result = array('status' => 'running');
$cmd_result = trim($backend->configdRun('firmware status'));
$result['log'] = $cmd_result;
if (trim($cmd_result) == "Execute error") {
$result["status"] = "error";
if (trim($cmd_result) == 'Execute error') {
$result['status'] = 'error';
} elseif (strpos($cmd_result, '***DONE***') !== false) {
$result["status"] = "done";
$result['status'] = 'done';
} elseif (strpos($cmd_result, '***REBOOT***') !== false) {
$result["status"] = "reboot";
$result['status'] = 'reboot';
}
return $result;
}
......
......@@ -175,13 +175,14 @@ POSSIBILITY OF SUCH DAMAGE.
ajaxGet('/api/core/firmware/info', {}, function (data, status) {
$("#packageslist").html("<tr><th>{{ lang._('Name') }}</th>" +
"<th>{{ lang._('Version') }}</th><th>{{ lang._('Size') }}</th>" +
"<th>{{ lang._('Comment') }}</th></tr>");
"<th>{{ lang._('Comment') }}</th><th>{{ lang._('Action') }}</th></tr>");
$.each(data['local'], function(index, row) {
$('#packageslist').append('<tr>' +
'<td>' + row['name'] + '</td>' +
'<td>' + row['version'] + '</td>' +
'<td>' + row['flatsize'] + '</td>' +
'<td>' + row['comment'] + '</td>' +
'<td>reinstall</td>' +
'</tr>');
});
});
......
#!/bin/sh
# Copyright (C) 2015 Franco Fichtner <franco@opnsense.org>
# Copyright (C) 2014 Deciso B.V.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress
PACKAGE=$1
# Check if another pkg process is already running
if [ -n "$(pgrep pkg)" ]; then
exit 0
fi
# Truncate upgrade progress file
: > ${PKG_PROGRESS_FILE}
echo "***GOT REQUEST TO REINSTALL: $PACKAGE***" >> ${PKG_PROGRESS_FILE}
echo '***STARTING REINSTALL***' >> ${PKG_PROGRESS_FILE}
pkg install -yf $PACKAGE >> ${PKG_PROGRESS_FILE}
pkg autoremove -y >> ${PKG_PROGRESS_FILE}
pkg clean -ya >> ${PKG_PROGRESS_FILE}
echo '***DONE***' >> ${PKG_PROGRESS_FILE}
#!/bin/sh
# Copyright (C) 2015 Franco Fichtner <franco@opnsense.org>
# Copyright (C) 2014 Deciso B.V.
# All rights reserved.
#
......@@ -24,39 +25,37 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package=$1
# Check if another pkg process is already running
pkg_running=`ps -x | grep "pkg " | grep -v "grep" | grep -v "pkg_upgrade.sh"`
PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress
PACKAGE=$1
REBOOT=
# Check if another pkg process is already running
if [ -n "$(pgrep pkg)" ]; then
exit 0
fi
# Truncate upgrade progress file
: > ${PKG_PROGRESS_FILE}
echo "***GOT REQUEST TO UPGRADE: $package***" >> ${PKG_PROGRESS_FILE}
echo "***GOT REQUEST TO UPGRADE: $PACKAGE***" >> ${PKG_PROGRESS_FILE}
if [ -z "$pkg_running" ]; then
echo '***STARTING UPGRADE***' >> ${PKG_PROGRESS_FILE}
if [ "$package" == "all" ]; then
# update all installed packages
opnsense-update -p >> ${PKG_PROGRESS_FILE}
# restart the web server
/usr/local/etc/rc.restart_webgui >> ${PKG_PROGRESS_FILE}
# if we can update base, we'll do that as well
if opnsense-update -c; then
if opnsense-update -bk >> ${PKG_PROGRESS_FILE}; then
REBOOT=1
fi
echo '***STARTING UPGRADE***' >> ${PKG_PROGRESS_FILE}
if [ "$PACKAGE" == "all" ]; then
# update all installed packages
opnsense-update -p >> ${PKG_PROGRESS_FILE}
# restart the web server
/usr/local/etc/rc.restart_webgui >> ${PKG_PROGRESS_FILE}
# if we can update base, we'll do that as well
if opnsense-update -c; then
if opnsense-update -bk >> ${PKG_PROGRESS_FILE}; then
REBOOT=1
fi
elif [ "$package" == "pkg" ]; then
pkg upgrade -y $package >> ${PKG_PROGRESS_FILE}
echo "*** PLEASE CHECK FOR MORE UPGRADES"
else
echo "Cannot update $package" >> ${PKG_PROGRESS_FILE}
fi
elif [ "$PACKAGE" == "pkg" ]; then
pkg upgrade -y $PACKAGE >> ${PKG_PROGRESS_FILE}
echo "*** PLEASE CHECK FOR MORE UPGRADES"
else
echo 'Upgrade already in progress' >> ${PKG_PROGRESS_FILE}
echo "Cannot update $PACKAGE" >> ${PKG_PROGRESS_FILE}
fi
if [ -n "${REBOOT}" ]; then
......
......@@ -5,12 +5,18 @@ type:script_output
message:retrieve package status
[upgrade]
command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/pkg_upgrade.sh
command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/firmware/upgrade.sh
parameters:%s
type:script
message:perform upgrade %s
message:upgrading %s
[upgrade_status]
[reinstall]
command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/firmware/reinstall.sh
parameters:%s
type:script
message: reinstalling firmware package %s
[status]
command:cat /tmp/pkg_upgrade.progress 2>&1
parameters:
type:script_output
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment