Commit 5a3a3a84 authored by Franco Fichtner's avatar Franco Fichtner

firmware: add running API action and reattach if possible; closes #646

parent 2e10248c
......@@ -316,6 +316,19 @@ class FirmwareController extends ApiControllerBase
return $response;
}
/**
* retrieve exectution status
*/
public function runningAction()
{
$backend = new Backend();
$result = array(
'status' => trim($backend->configdRun('firmware running'))
);
return $result;
}
/**
* retrieve upgrade status (and log file of current process)
*/
......
......@@ -85,7 +85,8 @@ POSSIBILITY OF SUCH DAMAGE.
*/
function upgrade(){
$('#progresstab > a').tab('show');
$('#updatestatus').html("{{ lang._('Upgrading... (do not leave this page while upgrade is in progress)') }}");
$('#updatestatus').html("{{ lang._('Upgrading...') }}");
$("#upgrade").attr("style","");
$("#upgrade_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall('/api/core/firmware/upgrade',{upgrade:$.upgrade_action},function() {
......@@ -102,7 +103,7 @@ POSSIBILITY OF SUCH DAMAGE.
function action(pkg_act, pkg_name)
{
$('#progresstab > a').tab('show');
$('#updatestatus').html("{{ lang._('Executing... (do not leave this page while execute is in progress)') }}");
$('#updatestatus').html("{{ lang._('Executing...') }}");
ajaxCall('/api/core/firmware/'+pkg_act+'/'+pkg_name,{},function() {
$('#updatelist').empty();
......@@ -136,7 +137,6 @@ POSSIBILITY OF SUCH DAMAGE.
}]
});
} else {
upgrade();
}
......@@ -178,7 +178,7 @@ POSSIBILITY OF SUCH DAMAGE.
"{{ lang._('The upgrade has finished and your device is being rebooted at the moment, please wait...') }}" +
' <i class="fa fa-cog fa-spin"></i>'
);
setTimeout(rebootWait, 30000);
setTimeout(rebootWait, 45000);
},
});
} else {
......@@ -292,14 +292,20 @@ POSSIBILITY OF SUCH DAMAGE.
if ($('#message').html() != '') {
$('#message').attr('style', '');
}
// repopulate package information
packagesInfo();
ajaxGet('/api/core/firmware/running',{},function(data, status) {
// if action is already running reattach now...
if (data['status'] == 'busy') {
upgrade();
// dashboard link: run check automatically
if (window.location.hash == '#checkupdate') {
} else if (window.location.hash == '#checkupdate') {
updateStatus();
}
});
});
</script>
<div class="container-fluid">
......
#!/bin/sh
# Copyright (C) 2016 Franco Fichtner <franco@opnsense.org>
# 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.
LOCKFILE="/tmp/pkg_upgrade.progress"
FLOCK="/usr/local/bin/flock -n"
(
if ${FLOCK} 9; then
echo "ready"
else
echo "busy"
fi
) 9< ${LOCKFILE}
......@@ -2,7 +2,13 @@
command:/usr/local/opnsense/scripts/firmware/check.sh
parameters:
type:script_output
message:retrieve package status
message:retrieve firmware update status
[running]
command:/usr/local/opnsense/scripts/firmware/running.sh
parameters:
type:script_output
message:retrieve firmware execution status
[upgrade]
command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/firmware/launcher.sh upgrade
......
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