This commit is contained in:
Bozhidar 2024-05-14 12:40:53 +03:00
parent 691bcb7c85
commit 0f8b14764b
2 changed files with 13 additions and 9 deletions

View file

@ -3,6 +3,7 @@
namespace App\Console\Commands;
use App\Models\Domain;
use App\VirtualHosts\ApacheBuild;
use Illuminate\Console\Command;
class RunDomainRepair extends Command
@ -26,13 +27,8 @@ class RunDomainRepair extends Command
*/
public function handle()
{
$getAllDomains = Domain::all();
if ($getAllDomains->count() > 0) {
foreach ($getAllDomains as $domain) {
$this->info('Repair domain: ' . $domain->domain);
$domain->configureVirtualHost(false);
}
shell_exec('service apache2 restart');
}
$apache = new ApacheBuild();
$apache->fixPermissions();
$apache->build();
}
}

View file

@ -6,6 +6,14 @@ use App\Models\Domain;
class ApacheBuild
{
public $fixPermissions = false;
public function fixPermissions()
{
$this->fixPermissions = true;
}
public function build()
{
$virtualHostMerged = '
@ -77,7 +85,7 @@ IncludeOptional conf-enabled/*.conf
$getAllDomains = Domain::all();
foreach ($getAllDomains as $domain) {
$domainVirtualHost = $domain->configureVirtualHost(false);
$domainVirtualHost = $domain->configureVirtualHost($this->fixPermissions);
if (isset($domainVirtualHost['apacheBaseConfig'])) {
$virtualHostMerged .= $domainVirtualHost['apacheBaseConfig'] . "\n\n";
}