mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 09:00:27 +00:00
update
This commit is contained in:
parent
5234176826
commit
7ead05557e
4 changed files with 133 additions and 54 deletions
69
web/Modules/Microweber/App/Actions/MicroweberScanner.php
Normal file
69
web/Modules/Microweber/App/Actions/MicroweberScanner.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Microweber\App\Actions;
|
||||
|
||||
use App\Models\Domain;
|
||||
use MicroweberPackages\SharedServerScripts\MicroweberInstallationsScanner;
|
||||
use Modules\Microweber\App\Models\MicroweberInstallation;
|
||||
|
||||
class MicroweberScanner
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$findDomains = Domain::all();
|
||||
foreach ($findDomains as $domain) {
|
||||
|
||||
if (!is_dir($domain->domain_public)) {
|
||||
$deleteInstallation = MicroweberInstallation::where('domain_id', $domain->id)
|
||||
->get();
|
||||
if ($deleteInstallation != null) {
|
||||
foreach ($deleteInstallation as $delete) {
|
||||
$delete->delete();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$scan = new MicroweberInstallationsScanner();
|
||||
$scan->setPath($domain->domain_public);
|
||||
|
||||
$installations = $scan->scanRecusrive();
|
||||
|
||||
if (! empty($installations)) {
|
||||
foreach ($installations as $installation) {
|
||||
|
||||
$findInstallation = MicroweberInstallation::where('installation_path', $installation['path'])
|
||||
->where('domain_id', $domain->id)
|
||||
->first();
|
||||
|
||||
if (! $findInstallation) {
|
||||
$findInstallation = new MicroweberInstallation();
|
||||
$findInstallation->domain_id = $domain->id;
|
||||
$findInstallation->installation_path = $installation['path'];
|
||||
}
|
||||
|
||||
$findInstallation->app_version = $installation['version'];
|
||||
$findInstallation->template = $installation['app_details']['template'];
|
||||
|
||||
if ($installation['is_symlink']) {
|
||||
$findInstallation->installation_type = 'symlink';
|
||||
} else {
|
||||
$findInstallation->installation_type = 'standalone';
|
||||
}
|
||||
|
||||
$findInstallation->save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$getAppInstallations = MicroweberInstallation::get();
|
||||
if ($getAppInstallations != null) {
|
||||
foreach ($getAppInstallations as $appInstallation) {
|
||||
if (! is_file($appInstallation['installation_path'].'/config/microweber.php')) {
|
||||
$appInstallation->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Microweber\App\Console\Commands;
|
||||
|
||||
use App\Models\Domain;
|
||||
use Illuminate\Console\Command;
|
||||
use MicroweberPackages\SharedServerScripts\MicroweberReinstaller;
|
||||
use Modules\Microweber\App\Actions\MicroweberScanner;
|
||||
use Modules\Microweber\App\Models\MicroweberInstallation;
|
||||
|
||||
class RunDomainRepair extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'microweber:run-domain-repair';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// $newMwScan = new MicroweberScanner();
|
||||
// $newMwScan->handle();
|
||||
|
||||
$getMwInstallations = MicroweberInstallation::all();
|
||||
if ($getMwInstallations->count() > 0) {
|
||||
foreach ($getMwInstallations as $mwInstallation) {
|
||||
|
||||
$domain = $mwInstallation->domain()->first();
|
||||
if (!$domain) {
|
||||
$this->info('Domain not found: ' . $mwInstallation->domain_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->info('Repair domain: ' . $domain->domain);
|
||||
|
||||
$microweberReinstall = new MicroweberReinstaller();
|
||||
$microweberReinstall->setSymlinkInstallation();
|
||||
$microweberReinstall->setChownUser($domain->domain_username);
|
||||
$microweberReinstall->setPath($domain->domain_public);
|
||||
$microweberReinstall->setSourcePath(config('microweber.sharedPaths.app'));
|
||||
|
||||
$reinstallStatus = $microweberReinstall->run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ use BladeUI\Icons\Factory;
|
|||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Microweber\App\Console\Commands\RunDomainRepair;
|
||||
use Modules\Microweber\Listeners\DomainIsCreatedListener;
|
||||
use Modules\Microweber\MicroweberApacheVirtualHostConfig;
|
||||
|
||||
|
@ -54,7 +55,9 @@ class MicroweberServiceProvider extends ServiceProvider
|
|||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
$this->commands([
|
||||
RunDomainRepair::class
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Models\Domain;
|
|||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use MicroweberPackages\SharedServerScripts\MicroweberInstallationsScanner;
|
||||
use Modules\Microweber\App\Actions\MicroweberScanner;
|
||||
use Modules\Microweber\App\Models\MicroweberInstallation;
|
||||
use Modules\Microweber\Filament\Clusters\Microweber\Resources\InstallationResource;
|
||||
|
||||
|
@ -23,60 +24,9 @@ class ListInstallations extends ListRecords
|
|||
|
||||
public function scanForInstallations()
|
||||
{
|
||||
$findDomains = Domain::all();
|
||||
foreach ($findDomains as $domain) {
|
||||
|
||||
if (!is_dir($domain->domain_public)) {
|
||||
$deleteInstallation = MicroweberInstallation::where('domain_id', $domain->id)
|
||||
->get();
|
||||
if ($deleteInstallation != null) {
|
||||
foreach ($deleteInstallation as $delete) {
|
||||
$delete->delete();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$newMwScan = new MicroweberScanner();
|
||||
$newMwScan->handle();
|
||||
|
||||
$scan = new MicroweberInstallationsScanner();
|
||||
$scan->setPath($domain->domain_public);
|
||||
|
||||
$installations = $scan->scanRecusrive();
|
||||
|
||||
if (! empty($installations)) {
|
||||
foreach ($installations as $installation) {
|
||||
|
||||
$findInstallation = MicroweberInstallation::where('installation_path', $installation['path'])
|
||||
->where('domain_id', $domain->id)
|
||||
->first();
|
||||
|
||||
if (! $findInstallation) {
|
||||
$findInstallation = new MicroweberInstallation();
|
||||
$findInstallation->domain_id = $domain->id;
|
||||
$findInstallation->installation_path = $installation['path'];
|
||||
}
|
||||
|
||||
$findInstallation->app_version = $installation['version'];
|
||||
$findInstallation->template = $installation['app_details']['template'];
|
||||
|
||||
if ($installation['is_symlink']) {
|
||||
$findInstallation->installation_type = 'symlink';
|
||||
} else {
|
||||
$findInstallation->installation_type = 'standalone';
|
||||
}
|
||||
|
||||
$findInstallation->save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$getAppInstallations = MicroweberInstallation::get();
|
||||
if ($getAppInstallations != null) {
|
||||
foreach ($getAppInstallations as $appInstallation) {
|
||||
if (! is_file($appInstallation['installation_path'].'/config/microweber.php')) {
|
||||
$appInstallation->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue