Skip to content

Commit

Permalink
Fix Update Check
Browse files Browse the repository at this point in the history
To be able to compare architectures, we have to exchange arch keys parsed from clients uname string
to match arch keys retrieved from remote site via ajax call.

E.g. for Ubuntu/Debian, architecture x86_64, parsed from FD uname string, has to be replaced with amd64
to be able to compare versions by architecture.

Additionally, let the application determine protocol to use for update retrieval (ajax/jsonp) itself.
  • Loading branch information
fbergkemper committed Mar 23, 2017
1 parent 8c4ecbc commit 6532614
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
19 changes: 18 additions & 1 deletion module/Auth/src/Auth/Controller/AuthController.php
Expand Up @@ -102,7 +102,24 @@ public function loginAction()
}

if(array_key_exists('obsarch', $dird_version)) {
$dird_arch = $dird_version['obsarch'];
if(preg_match("/ubuntu/i", $dird_dist) && $dird_version['obsarch'] == "x86_64") {
$dird_arch = "amd64";
}
elseif(preg_match("/debian/i", $dird_dist) && $dird_version['obsarch'] == "x86_64") {
$dird_arch = "amd64";
}
elseif(preg_match("/windows/i", $dird_dist) && $dird_version['obsarch'] == "Win32") {
$dird_arch = "32";
}
elseif(preg_match("/windows/i", $dird_dist) && $dird_version['obsarch'] == "Win64") {
$dird_arch = "64";
}
else {
$dird_arch = $dird_version['obsarch'];
}
}
else {
$dird_arch = null;
}

if(array_key_exists('version', $dird_version)) {
Expand Down
4 changes: 2 additions & 2 deletions module/Auth/view/auth/auth/login.phtml
Expand Up @@ -192,7 +192,7 @@ get latest versions information via ajax call

function getVersions() {

var update_url = "https://download.bareos.com/release-info/bareos-release-info.js?callback=jsonCallback";
var update_url = window.location.protocol + "//download.bareos.com/release-info/bareos-release-info.js?callback=jsonCallback";

var v = $.ajax({
method: "GET",
Expand All @@ -201,7 +201,7 @@ function getVersions() {
contentType: 'application/javascript',
dataType: 'jsonp',
timeout: 15000,
error: function() {
error: function(jqXHR, textStatus, errorThrown) {
return false;
},
success: function(result) {
Expand Down
34 changes: 31 additions & 3 deletions module/Client/src/Client/Controller/ClientController.php
Expand Up @@ -210,7 +210,21 @@ public function getDataAction()
}

if(array_key_exists('obsarch', $dird_version)) {
$dird_arch = $dird_version['obsarch'];
if(preg_match("/debian/i", $dird_dist) && $dird_version['obsarch'] == "x86_64") {
$dird_arch = "amd64";
}
elseif(preg_match("/ubuntu/i", $dird_dist) && $dird_version['obsarch'] == "x86_64") {
$dird_arch = "amd64";
}
elseif(preg_match("/windows/i", $dird_dist) && $dird_version['obsarch'] == "Win32") {
$dird_arch = "32";
}
elseif(preg_match("/windows/i", $dird_dist) && $dird_version['obsarch'] == "Win64") {
$dird_arch = "64";
}
else {
$dird_arch = $dird_version['obsarch'];
}
}
else {
$dird_arch = null;
Expand Down Expand Up @@ -283,10 +297,24 @@ public function getDataAction()
}

if(array_key_exists(4, $uname)) {
$fd_arch = $uname[4];
if(preg_match("/debian/i", $fd_dist) && $uname[4] == "x86_64") {
$fd_arch = "amd64";
}
elseif(preg_match("/ubuntu/i", $fd_dist) && $uname[4] == "x86_64") {
$fd_arch = "amd64";
}
elseif(preg_match("/windows/i", $fd_dist) && $uname[4] == "Win32") {
$fd_arch = "32";
}
elseif(preg_match("/windows/i", $fd_dist) && $uname[4] == "Win64") {
$fd_arch = "64";
}
else {
$fd_arch = $uname[4];
}
}
else {
$fd_arch = "";
$fd_arch = NULL;
}

$result[$i]['installed_fd'] = $fd_vers;
Expand Down

0 comments on commit 6532614

Please sign in to comment.