Kaydet (Commit) 7308de85 authored tarafından mertcelen's avatar mertcelen

Liman auto download mechanism added.

Homepage widgets fixed on other pages.
üst b87e9a95
......@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
use GuzzleHttp\Client;
use App\Extension;
use App\Jobs\ExtensionUpdaterJob;
use App\Jobs\LimanUpdaterJob;
use GuzzleHttp\Exception\BadResponseException;
use Illuminate\Contracts\Bus\Dispatcher;
......@@ -121,6 +122,14 @@ class MarketController extends Controller
"changeLog" => $obj["version"]["versionDescription"],
"extension_id" => $params[$i]["extension_id"],
]);
} else {
$job = (new LimanUpdaterJob(
$obj["version"]["versionName"],
$obj["platforms"][0]["downloadLink"]
))->onQueue('system_updater');
// Dispatch job right away.
$job_id = app(Dispatcher::class)->dispatch($job);
}
}
}
......
......@@ -745,6 +745,7 @@ if (!function_exists('checkHealth')) {
"server" => "0700",
"webssh" => "0700",
"modules" => "0700",
"packages" => "0700",
];
$messages = [];
......
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
class LimanUpdaterJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $downloadUrl;
protected $downloadTo;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($version, $downloadUrl)
{
$this->downloadUrl = $downloadUrl;
$this->downloadTo = "/liman/packages/liman-$version.deb";
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
self::downloadFile();
}
private function downloadFile()
{
if (is_file($this->downloadTo)) {
return true;
}
$client = new Client([
"headers" => [
"Authorization" => "Bearer " . env("MARKET_ACCESS_TOKEN"),
],
"verify" => false,
]);
$resource = fopen($this->downloadTo, 'w');
$client->request('GET', $this->downloadUrl, ['sink' => $resource]);
if (is_file($this->downloadTo)) {
return true;
} else {
return false;
}
}
}
#!/bin/bash
# Create Required Folders for Liman
mkdir -p /liman/{server,certs,logs,database,sandbox,keys,extensions,modules}
mkdir -p /liman/{server,certs,logs,database,sandbox,keys,extensions,modules,packages}
# environment creation
if [ -f "/liman/server/.env" ]; then
......@@ -140,8 +140,8 @@ rm -rf /tmp/liman
rm -rf /liman/sandbox/{.git,vendor,views,.gitignore,composer.json,composer.lock,index.php}
# Set Permissions
chown -R liman:liman /liman/{server,database,certs,sandbox,logs,webssh,modules}
chmod 700 -R /liman/{server,database,certs,logs,webssh,modules}
chown -R liman:liman /liman/{server,database,certs,sandbox,logs,webssh,modules,packages}
chmod 700 -R /liman/{server,database,certs,logs,webssh,modules,packages}
chmod 755 -R /liman/sandbox
chown liman:liman /{liman,liman/extensions,liman/keys}
chmod 755 /{liman,liman/extensions,liman/keys}
......
......@@ -149,6 +149,7 @@
}
</style>
<script>
var limanEnableWidgets = true;
$(".sortable-widget").sortable({
stop: function(event, ui) {
var data = [];
......@@ -189,6 +190,9 @@
},{{config('liman.widget_refresh_time')}});
function startQueue(){
if(!limanEnableWidgets){
return;
}
currentWidget = 0;
if(currentWidget >= widgets.length || widgets.length === 0){
return;
......@@ -201,6 +205,9 @@
}
@if(user()->isAdmin())
function retrieveStats(){
if(!limanEnableWidgets){
return;
}
request('{{route('liman_stats')}}', new FormData(), function(response){
var json = JSON.parse(response);
$("#ramUsage").text(json.ram);
......
......@@ -16,6 +16,9 @@
<script>
function partialPageRequest(url){
if(url != "/"){
limanEnableWidgets = false;
}
var form = new FormData();
var newUrl = url + "?partialRequest=true";
form.append('partialRequest',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