Commit e40a2895 authored by Jos Schellevis's avatar Jos Schellevis

Finalized System Information widget and pkg_updatecheck now updates version file when run

parent e6eb5c60
...@@ -62,6 +62,7 @@ timeout=30 # Wait for a maximum number of seconds to determine connection issues ...@@ -62,6 +62,7 @@ timeout=30 # Wait for a maximum number of seconds to determine connection issues
package_json_output="/tmp/pkg_status.json" package_json_output="/tmp/pkg_status.json"
tmp_pkg_output_file="/tmp/packages.output" tmp_pkg_output_file="/tmp/packages.output"
tmp_pkg_update_file="/tmp/pkg_updates.output" tmp_pkg_update_file="/tmp/pkg_updates.output"
version_file="/usr/local/etc/version"
# Check if pkg is already runnig # Check if pkg is already runnig
pkg_running=`ps -x | grep "pkg " | grep -v "grep"` pkg_running=`ps -x | grep "pkg " | grep -v "grep"`
...@@ -111,6 +112,7 @@ if [ "$pkg_running" == "" ]; then ...@@ -111,6 +112,7 @@ if [ "$pkg_running" == "" ]; then
updates="0" updates="0"
else else
core_version=`pkg info opnsense | grep 'Version' | awk -F '[:]' '{print $2}'` # Changed to reflect current installed core version core_version=`pkg info opnsense | grep 'Version' | awk -F '[:]' '{print $2}'` # Changed to reflect current installed core version
echo $core_version > $version_file; # Lets save the current version
required_space=`cat $tmp_pkg_output_file | grep 'The process will require' | awk -F '[ ]' '{print $5$6}'` required_space=`cat $tmp_pkg_output_file | grep 'The process will require' | awk -F '[ ]' '{print $5$6}'`
if [ "$required_space" == "" ]; then if [ "$required_space" == "" ]; then
required_space="none" required_space="none"
......
<?php <?php
/* /*
$Id$ Copyright (C) 2014 Deciso B.V.
Copyright 2007 Scott Dale Copyright 2007 Scott Dale
Part of pfSense widgets (https://www.pfsense.org) Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
originally based on m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
and Jonathan Watt <jwatt@jwatt.org>. and Jonathan Watt <jwatt@jwatt.org>.
All rights reserved. All rights reserved.
...@@ -47,20 +44,25 @@ if($_POST['action'] == 'pkg_update') { ...@@ -47,20 +44,25 @@ if($_POST['action'] == 'pkg_update') {
$shell->exec("/usr/local/opnsense/scripts/pkg_updatecheck.sh",false,false,$shell_output); $shell->exec("/usr/local/opnsense/scripts/pkg_updatecheck.sh",false,false,$shell_output);
} }
if (file_exists($file_pkg_status)) {
if($_REQUEST['getupdatestatus']) {
if (file_exists($file_pkg_status)) {
$json = file_get_contents($file_pkg_status); $json = file_get_contents($file_pkg_status);
$pkg_status = json_decode($json,true); $pkg_status = json_decode($json,true);
}
if ($pkg_status["updates"]=="0") { if($_REQUEST['getupdatestatus']) {
echo "Last check at (".$pkg_status["last_check"]."), you were up to date"; if (file_exists($file_pkg_status)) {
if ($pkg_status["connection"]=="error") {
echo "<span class='text-danger'>".gettext("Connection Error")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to retry now")."</span>";
} elseif ($pkg_status["repository"]=="error") {
echo "<span class='text-danger'>".gettext("Repository Problem")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to retry now")."</span>";
} elseif ($pkg_status["updates"]=="0") {
echo "<span class='text-info'>".gettext("At")." <small>".$pkg_status["last_check"]."</small>".gettext(" no updates found.")."<br/><span class='btn-link' onclick='checkupdate()'>Click to check now</span>";
} else { } else {
echo "<span class='text-danger'>A total of ".$pkg_status["updates"]." update(s) are available.</span>"; echo "<span class='text-danger'>".gettext("A total of ").$pkg_status["updates"].gettext(" update(s) are available.")."</span><br/><a href='/system_firmware.php'>".gettext("Click to update")."</a>";
} }
} else { } else {
echo "Unknown<span class='btn-link' onclick='checkupdate()'>Click to check now</span>"; echo "<span class='text-danger'>".gettext("Unknown")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to check now")."</span>";
} }
exit; exit;
} }
...@@ -102,7 +104,7 @@ $filesystems = get_mounted_filesystems(); ...@@ -102,7 +104,7 @@ $filesystems = get_mounted_filesystems();
<tr> <tr>
<td width="25%" valign="top" class="vncellt"><?=gettext("Version");?></td> <td width="25%" valign="top" class="vncellt"><?=gettext("Version");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
<strong><?php readfile("/usr/local/etc/version"); ?></strong> <strong><?php readfile("/usr/local/etc/version"); ?><span id="version"></span></strong>
(<?php echo php_uname("m"); ?>) (<?php echo php_uname("m"); ?>)
<?php if(!$g['hideuname']): ?> <?php if(!$g['hideuname']): ?>
<br /> <br />
...@@ -312,7 +314,7 @@ $filesystems = get_mounted_filesystems(); ...@@ -312,7 +314,7 @@ $filesystems = get_mounted_filesystems();
jQuery('#uname').html("<?php echo php_uname("a"); ?>"); jQuery('#uname').html("<?php echo php_uname("a"); ?>");
} }
function checkupdate() { function checkupdate() {
jQuery('#updatestatus').html('<span class="text-info">Updating.... (takes about 10 seconds) </span>'); jQuery('#updatestatus').html('<span class="text-info">Updating.... (takes upto 30 seconds) </span>');
jQuery.ajax({ jQuery.ajax({
type: "POST", type: "POST",
url: '/widgets/widgets/system_information.widget.php', url: '/widgets/widgets/system_information.widget.php',
......
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