Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
0b6c6af8
Commit
0b6c6af8
authored
Aug 12, 2015
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firmware: merge feature improvements from master
parent
4b9f1077
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
58 deletions
+44
-58
FirmwareController.php
.../app/controllers/OPNsense/Core/Api/FirmwareController.php
+30
-21
firmware.volt
src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt
+11
-32
pkg_updatecheck.sh
src/opnsense/scripts/pkg_updatecheck.sh
+2
-4
system_information.widget.php
src/www/widgets/widgets/system_information.widget.php
+1
-1
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php
View file @
0b6c6af8
...
...
@@ -45,31 +45,40 @@ class FirmwareController extends ApiControllerBase
{
$this
->
sessionClose
();
// long running action, close session
$backend
=
new
Backend
();
$response
=
json_decode
(
trim
(
$backend
->
configdRun
(
"firmware pkgstatus"
)),
true
);
$response
=
json_decode
(
trim
(
$backend
->
configdRun
(
'firmware pkgstatus'
)),
true
);
if
(
$response
!=
null
)
{
if
(
array_key_exists
(
"connection"
,
$response
)
&&
$response
[
"connection"
]
==
"error"
)
{
$response
[
"status"
]
=
"error"
;
$response
[
"status_msg"
]
=
"Connection Error"
;
}
elseif
(
array_key_exists
(
"repository"
,
$response
)
&&
$response
[
"repository"
]
==
"error"
)
{
$response
[
"status"
]
=
"error"
;
$response
[
"status_msg"
]
=
"Repository Problem"
;
}
elseif
(
array_key_exists
(
"updates"
,
$response
)
&&
$response
[
'updates'
]
==
0
)
{
$response
[
"status"
]
=
"none"
;
$response
[
"status_msg"
]
=
"no updates found"
;
}
elseif
(
array_key_exists
(
0
,
$response
[
"upgrade_packages"
])
&&
$response
[
"upgrade_packages"
][
0
][
"name"
]
==
"pkg"
)
{
$response
[
"status"
]
=
"ok"
;
$response
[
"status_upgrade_action"
]
=
"pkg"
;
$response
[
"status_msg"
]
=
"There is a mandatory update for the package manager. "
.
"Please install and check for updates again."
;
}
elseif
(
array_key_exists
(
"updates"
,
$response
))
{
$response
[
"status"
]
=
"ok"
;
$response
[
"status_upgrade_action"
]
=
"all"
;
$response
[
"status_msg"
]
=
sprintf
(
"A total of %s update(s) are available."
,
$response
[
"updates"
]);
if
(
array_key_exists
(
'connection'
,
$response
)
&&
$response
[
'connection'
]
==
'error'
)
{
$response
[
'status_msg'
]
=
'Connection error.'
;
$response
[
'status'
]
=
'error'
;
}
elseif
(
array_key_exists
(
'repository'
,
$response
)
&&
$response
[
'repository'
]
==
'error'
)
{
$response
[
'status_msg'
]
=
'Repository problem.'
;
$response
[
'status'
]
=
'error'
;
}
elseif
(
array_key_exists
(
'updates'
,
$response
)
&&
$response
[
'updates'
]
==
0
)
{
$response
[
'status_msg'
]
=
'There are no updates available.'
;
$response
[
'status'
]
=
'none'
;
}
elseif
(
array_key_exists
(
0
,
$response
[
'upgrade_packages'
])
&&
$response
[
'upgrade_packages'
][
0
][
'name'
]
==
'pkg'
)
{
$response
[
'status_upgrade_action'
]
=
'pkg'
;
$response
[
'status'
]
=
'ok'
;
$response
[
'status_msg'
]
=
'There is a mandatory update for the package manager available. '
.
'Please install and fetch updates again.'
;
}
elseif
(
array_key_exists
(
'updates'
,
$response
))
{
$response
[
'status_upgrade_action'
]
=
'all'
;
$response
[
'status'
]
=
'ok'
;
if
(
$response
[
'updates'
]
==
1
)
{
/* keep this dynamic for template translation even though %s is always '1' */
$response
[
'status_msg'
]
=
sprintf
(
'There is %s update available.'
,
$response
[
'updates'
]);
}
else
{
$response
[
'status_msg'
]
=
sprintf
(
'There are %s updates available.'
,
$response
[
'updates'
]);
}
if
(
$response
[
'upgrade_needs_reboot'
]
==
1
)
{
$response
[
'status_msg'
]
=
sprintf
(
'%s %s'
,
$response
[
'status_msg'
],
'This update requires a reboot.'
);
}
}
}
else
{
$response
=
array
(
"status"
=>
"unknown"
,
"status_msg"
=>
"Current status is unknown"
);
$response
=
array
(
'status'
=>
'unknown'
,
'status_msg'
=>
'Current status is unknown.'
);
}
return
$response
;
...
...
src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt
View file @
0b6c6af8
...
...
@@ -36,21 +36,12 @@ POSSIBILITY OF SUCH DAMAGE.
$('#updatelist').empty();
$('#maintabs li:eq(1) a').tab('show');
$("#checkupdate_progress").addClass("fa fa-spinner fa-pulse");
$('#updatestatus').attr('class', 'text-info');
$('#updatestatus').html("{{ lang._('Updating.... (may take up to 30 seconds)') }}");
$('#updatestatus').html("{{ lang._('Fetching... (may take up to 30 seconds)') }}");
// request status
ajaxGet('/api/core/firmware/status',{},function(data,status){
// update UI
if (data['status'] == 'unknown') {
$('#updatestatus').attr('class', 'text-warning');
} else if (data['status'] == 'error') {
$('#updatestatus').attr('class', 'text-danger');
} else if (data['status'] == 'none' || data['status'] == 'ok') {
$('#updatestatus').attr('class', 'text-info');
}
$('#updatestatus').html(data['status_msg']);
$("#checkupdate_progress").removeClass("fa fa-spinner fa-pulse");
$('#updatestatus').html(data['status_msg']);
if (data['status'] == "ok") {
$.upgrade_action = data['status_upgrade_action'];
...
...
@@ -91,11 +82,10 @@ POSSIBILITY OF SUCH DAMAGE.
*/
function upgrade(){
$('#maintabs li:eq(2) a').tab('show');
$('#updatestatus').html("{{ lang._('
Starting Upgrade.. Please do not leave this page while upgrade is in progress.
') }}");
$('#updatestatus').html("{{ lang._('
Upgrading... (do not leave this page while upgrade is in progress)
') }}");
$("#upgrade_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall('/api/core/firmware/upgrade',{upgrade:$.upgrade_action},function() {
$("#upgrade_progress").removeClass("fa fa-spinner fa-pulse");
$('#updatelist').empty();
setTimeout(trackStatus, 500);
});
...
...
@@ -152,19 +142,19 @@ POSSIBILITY OF SUCH DAMAGE.
$('#update_status').scrollTop($('#update_status')[0].scrollHeight);
}
if (data['status'] == 'done') {
$("#upgrade_progress").removeClass("fa fa-spinner fa-pulse");
$('#updatestatus').html("{{ lang._('Upgrade done!') }}");
$("#upgrade").attr("style","display:none");
packagesInfo();
} else if (data['status'] == 'reboot') {
// reboot required, tell the user to wait until this is finished and redirect after 5 minutes
BootstrapDialog.show({
type:BootstrapDialog.TYPE_INFO,
title: "{{ lang._('Your device is rebooting') }}",
message: "{{ lang._('The upgrade is finished and your device is being rebooted at the moment, please wait.') }}",
closable: false,
onshow:function(dialogRef){
dialogRef.setClosable(false);
dialogRef.getModalBody().html(
"{{ lang._('The upgrade
i
s finished and your device is being rebooted at the moment, please wait...') }}" +
"{{ lang._('The upgrade
ha
s finished and your device is being rebooted at the moment, please wait...') }}" +
' <i class="fa fa-cog fa-spin"></i>'
);
setTimeout(rebootWait, 30000);
...
...
@@ -208,21 +198,10 @@ POSSIBILITY OF SUCH DAMAGE.
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<strong>{{ lang._('Current Firmware Status :')}}</strong>
<br/>
<span class="text-info" id="updatestatus">{{ lang._('Current status is unknown')}} </span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button class='btn btn-primary' id="checkupdate"><i id="checkupdate_progress" class=""></i> {{ lang._('Click to check now')}}</button>
<button class='btn btn-primary' id="upgrade" style="display:none"><i id="upgrade_progress" class=""></i> {{ lang._('Upgrade') }} </button>
</div>
</div>
<div class="row">
<div class="col-md-12">
<br/>
<div class="alert alert-info" role="alert" style="min-height: 65px;">
<button class='btn btn-primary pull-right' id="upgrade" style="display:none"><i id="upgrade_progress" class=""></i> {{ lang._('Upgrade now') }}</button>
<button class='btn btn-default pull-right' id="checkupdate" style="margin-right: 8px;"><i id="checkupdate_progress" class=""></i> {{ lang._('Fetch updates')}}</button>
<div style="margin-top: 8px;" id="updatestatus">{{ lang._('Click to check for updates.')}}</div>
</div>
</div>
<div class="row">
...
...
@@ -242,7 +221,7 @@ POSSIBILITY OF SUCH DAMAGE.
</table>
</div>
<div id="progress" class="tab-pane fade in">
<textarea name="output" id="update_status" class="form-control" rows="
1
0" wrap="hard" readonly style="max-width:100%; font-family: monospace;"></textarea>
<textarea name="output" id="update_status" class="form-control" rows="
2
0" wrap="hard" readonly style="max-width:100%; font-family: monospace;"></textarea>
</div>
</div>
</div>
...
...
src/opnsense/scripts/pkg_updatecheck.sh
View file @
0b6c6af8
...
...
@@ -165,15 +165,13 @@ if [ "$pkg_running" == "" ]; then
# Check if there are packages that need to be reinstalled
for
i
in
$(
cat
$tmp_pkg_output_file
|
cut
-d
'('
-f1
)
;
do
#echo $i
if
[
"
$itemcount
"
-gt
"
$linecount
"
]
;
then
#echo $i
if
[
`
echo
$linecount
+ 1 | bc
`
-eq
"
$itemcount
"
]
;
then
if
[
"
`
echo
$i
|
grep
'-'
`
"
==
""
]
;
then
itemcount
=
0
# This is not a valid item so reset item count
else
name
=
`
echo
$i
|
cut
-d
'-'
-f1
`
version
=
`
echo
$i
|
cut
-d
'-'
-f2
`
name
=
${
i
%-*
}
version
=
${
i
##*-
}
itemcount
=
`
echo
$itemcount
+ 1 | bc
`
# Get ready for next item
if
[
"
$packages_reinstall
"
==
""
]
;
then
packages_reinstall
=
$packages_reinstall
"{
\"
name
\"
:
\"
$name
\"
,"
# If it is the first item then we do not want a seperator
...
...
src/www/widgets/widgets/system_information.widget.php
View file @
0b6c6af8
...
...
@@ -287,7 +287,7 @@ endforeach; ?>
<script
type=
"text/javascript"
>
//
<!
[
CDATA
[
function
checkupdate
()
{
jQuery
(
'
#updatestatus
'
).
html
(
'
<span class="text-info">
Updating.
... (may take up to 30 seconds)</span>
'
);
jQuery
(
'
#updatestatus
'
).
html
(
'
<span class="text-info">
Fetching
... (may take up to 30 seconds)</span>
'
);
jQuery
.
ajax
({
type
:
"
POST
"
,
url
:
'
/widgets/widgets/system_information.widget.php
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment