This commit is contained in:
Bozhidar 2024-04-30 18:07:07 +03:00
parent 3e3e0633df
commit b59e42ccdf
2 changed files with 13 additions and 39 deletions

View file

@ -1,36 +0,0 @@
<?php
namespace App\Actions;
use App\ShellApi;
class ApacheWebsiteDelete
{
public $domain;
public function setDomain($domain)
{
$this->domain = $domain;
}
public function handle()
{
if (empty($this->domain)) {
return false;
}
$apacheConf = '/etc/apache2/sites-available/'.$this->domain.'.conf';
shell_exec('rm -rf '.$apacheConf);
$apacheConfEnabled = '/etc/apache2/sites-enabled/'.$this->domain.'.conf';
shell_exec('rm -rf '.$apacheConfEnabled);
// SSL
$apacheSSLConf = '/etc/apache2/sites-available/'.$this->domain.'-ssl.conf';
shell_exec('rm -rf '.$apacheSSLConf);
$apacheSSLConfEnabled = '/etc/apache2/sites-enabled/'.$this->domain.'-ssl.conf';
shell_exec('rm -rf '.$apacheSSLConfEnabled);
}
}

View file

@ -98,9 +98,19 @@ class Domain extends Model
shell_exec('rm -rf '.$model->domain_public); shell_exec('rm -rf '.$model->domain_public);
$deleteApacheWebsite = new ApacheWebsiteDelete(); $apacheConf = '/etc/apache2/sites-available/'.$model->domain.'.conf';
$deleteApacheWebsite->setDomain($model->domain); shell_exec('rm -rf '.$apacheConf);
$deleteApacheWebsite->handle();
$apacheConfEnabled = '/etc/apache2/sites-enabled/'.$model->domain.'.conf';
shell_exec('rm -rf '.$apacheConfEnabled);
// SSL
$apacheSSLConf = '/etc/apache2/sites-available/'.$model->domain.'-ssl.conf';
shell_exec('rm -rf '.$apacheSSLConf);
$apacheSSLConfEnabled = '/etc/apache2/sites-enabled/'.$model->domain.'-ssl.conf';
shell_exec('rm -rf '.$apacheSSLConfEnabled);
}); });
} }