Commit a5c4d51d 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.
parent 9e07e782
...@@ -5,10 +5,10 @@ upgrade to the new 16.1 series is seamless, except for the following ...@@ -5,10 +5,10 @@ upgrade to the new 16.1 series is seamless, except for the following
points:</p> points:</p>
<p><ul><li>The FreeBSD version changes from 10.1 to 10.2, mainly for driver <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 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 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 <em>/etc/fstab</em> before performing the major upgrade. A reinstall using the
install will work just as well.</li> import configuration and quick/easy install will work just as well.</li>
<li>The captive portal implementation has been completely rewritten. <li>The captive portal implementation has been completely rewritten.
<strong>Your old setup won't be converted and thus will not come back <strong>Your old setup won't be converted and thus will not come back
up</strong>. Reconfiguring the captive portal, however, will be relatively up</strong>. Reconfiguring the captive portal, however, will be relatively
......
...@@ -122,20 +122,19 @@ class FirmwareController extends ApiControllerBase ...@@ -122,20 +122,19 @@ class FirmwareController extends ApiControllerBase
public function upgradestatusAction() public function upgradestatusAction()
{ {
$backend = new Backend(); $backend = new Backend();
$result = array("status"=>"running"); $result = array('status' => 'running');
$cmd_result = trim($backend->configdRun("firmware upgrade_status")); $cmd_result = trim($backend->configdRun('firmware status'));
$result['log'] = $cmd_result; $result['log'] = $cmd_result;
if (trim($cmd_result) == "Execute error") { if (trim($cmd_result) == 'Execute error') {
$result["status"] = "error"; $result['status'] = 'error';
} elseif (strpos($cmd_result, '***DONE***') !== false) { } elseif (strpos($cmd_result, '***DONE***') !== false) {
$result["status"] = "done"; $result['status'] = 'done';
} elseif (strpos($cmd_result, '***REBOOT***') !== false) { } elseif (strpos($cmd_result, '***REBOOT***') !== false) {
$result["status"] = "reboot"; $result['status'] = 'reboot';
} }
return $result; return $result;
} }
......
...@@ -175,13 +175,14 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -175,13 +175,14 @@ POSSIBILITY OF SUCH DAMAGE.
ajaxGet('/api/core/firmware/info', {}, function (data, status) { ajaxGet('/api/core/firmware/info', {}, function (data, status) {
$("#packageslist").html("<tr><th>{{ lang._('Name') }}</th>" + $("#packageslist").html("<tr><th>{{ lang._('Name') }}</th>" +
"<th>{{ lang._('Version') }}</th><th>{{ lang._('Size') }}</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) { $.each(data['local'], function(index, row) {
$('#packageslist').append('<tr>' + $('#packageslist').append('<tr>' +
'<td>' + row['name'] + '</td>' + '<td>' + row['name'] + '</td>' +
'<td>' + row['version'] + '</td>' + '<td>' + row['version'] + '</td>' +
'<td>' + row['flatsize'] + '</td>' + '<td>' + row['flatsize'] + '</td>' +
'<td>' + row['comment'] + '</td>' + '<td>' + row['comment'] + '</td>' +
'<td>reinstall</td>' +
'</tr>'); '</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 #!/bin/sh
# Copyright (C) 2015 Franco Fichtner <franco@opnsense.org>
# Copyright (C) 2014 Deciso B.V. # Copyright (C) 2014 Deciso B.V.
# All rights reserved. # All rights reserved.
# #
...@@ -24,21 +25,22 @@ ...@@ -24,21 +25,22 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # 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 PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress
PACKAGE=$1
REBOOT= REBOOT=
# Check if another pkg process is already running
if [ -n "$(pgrep pkg)" ]; then
exit 0
fi
# Truncate upgrade progress file # Truncate upgrade progress file
: > ${PKG_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}
echo '***STARTING UPGRADE***' >> ${PKG_PROGRESS_FILE} if [ "$PACKAGE" == "all" ]; then
if [ "$package" == "all" ]; then
# update all installed packages # update all installed packages
opnsense-update -p >> ${PKG_PROGRESS_FILE} opnsense-update -p >> ${PKG_PROGRESS_FILE}
# restart the web server # restart the web server
...@@ -49,14 +51,11 @@ if [ -z "$pkg_running" ]; then ...@@ -49,14 +51,11 @@ if [ -z "$pkg_running" ]; then
REBOOT=1 REBOOT=1
fi fi
fi fi
elif [ "$package" == "pkg" ]; then elif [ "$PACKAGE" == "pkg" ]; then
pkg upgrade -y $package >> ${PKG_PROGRESS_FILE} pkg upgrade -y $PACKAGE >> ${PKG_PROGRESS_FILE}
echo "*** PLEASE CHECK FOR MORE UPGRADES" echo "*** PLEASE CHECK FOR MORE UPGRADES"
else
echo "Cannot update $package" >> ${PKG_PROGRESS_FILE}
fi
else else
echo 'Upgrade already in progress' >> ${PKG_PROGRESS_FILE} echo "Cannot update $PACKAGE" >> ${PKG_PROGRESS_FILE}
fi fi
if [ -n "${REBOOT}" ]; then if [ -n "${REBOOT}" ]; then
......
...@@ -5,12 +5,18 @@ type:script_output ...@@ -5,12 +5,18 @@ type:script_output
message:retrieve package status message:retrieve package status
[upgrade] [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 parameters:%s
type:script 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 command:cat /tmp/pkg_upgrade.progress 2>&1
parameters: parameters:
type:script_output 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