Commit 42230362 authored by Franco Fichtner's avatar Franco Fichtner

firmware: almost always avoid writing json file for updates

This was leaking spurious json output sometimes, confusing
the firmware pages and its users.
parent ce0dc6d6
......@@ -61,7 +61,6 @@ timer=0
timeout=30 # Wait for a maximum number of seconds to determine connection issues
# File location variables
package_json_output="/tmp/pkg_status.json"
tmp_pkg_output_file="/tmp/packages.output"
tmp_pkg_update_file="/tmp/pkg_updates.output"
......@@ -233,12 +232,7 @@ if [ "$pkg_running" == "" ]; then
# Get date/timestamp
last_check=`date`
# Write our json structure to disk
echo "{\"connection\":\"$connection\",\"repository\":\"$repository\",\"last_check\":\"$last_check\",\"updates\":\"$updates\",\"core_version\":\"$core_version\",\"download_size\":\"$download_size\",\"extra_space_required\":\"$required_space\",\"new_packages\":[$packages_new],\"reinstall_packages\":[$packages_reinstall],\"upgrade_packages\":[$packages_upgraded],\"upgrade_needs_reboot\":\"$upgrade_needs_reboot\"}" > $package_json_output
echo "{\"connection\":\"$connection\",\"repository\":\"$repository\",\"last_check\":\"$last_check\",\"updates\":\"$updates\",\"core_version\":\"$core_version\",\"download_size\":\"$download_size\",\"extra_space_required\":\"$required_space\",\"new_packages\":[$packages_new],\"reinstall_packages\":[$packages_reinstall],\"upgrade_packages\":[$packages_upgraded],\"upgrade_needs_reboot\":\"$upgrade_needs_reboot\"}"
else
# pkg is already running, quitting
fi
# output json data
if [ -f $package_json_output ]; then
cat $package_json_output
fi
......@@ -35,13 +35,17 @@ require_once('notices.inc');
include_once("includes/functions.inc.php");
require_once("script/load_phalcon.php");
/* XXX keep redirect through file because we know it works, but zap this later */
$file_pkg_status = '/tmp/pkg_status.json';
if ($_POST['action'] == 'pkg_update') {
configd_run('firmware pkgstatus');
$pkg_json = trim(configd_run('firmware pkgstatus'));
if ($pkg_json != '') {
file_put_contents($file_pkg_status, $pkg_json);
}
}
if ($_REQUEST['getupdatestatus']) {
$file_pkg_status="/tmp/pkg_status.json";
if (file_exists($file_pkg_status)) {
$json = file_get_contents($file_pkg_status);
$pkg_status = json_decode($json, true);
......
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