Skip to content

Commit

Permalink
Update WildcardDomain.php
Browse files Browse the repository at this point in the history
  • Loading branch information
bobicloudvision committed Oct 31, 2024
1 parent 47c6512 commit 145064f
Showing 1 changed file with 33 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,93 +107,42 @@ public function installCertificates()
ApacheBuild::dispatchSync();

return [
'error' => 'Domain SSL certificate updated.'
'success' => 'Domain SSL certificate updated.'
];

}


//
//
//
// if (file_exists($this->installLogFilePath)) {
// unlink($this->installLogFilePath);
// }
//
// $acmeConfigYaml = view('letsencrypt::actions.acme-config-wildcard-yaml', [
// 'domain' => $masterDomain->domain,
// 'domainRoot' => $masterDomain->domainRoot,
// 'domainPublic' => $masterDomain->domainPublic,
// 'email' => $masterDomain->email,
// 'country' => $masterDomain->country,
// 'locality' => $masterDomain->locality,
// 'organization' => $masterDomain->organization
// ])->render();
//
// $acmeConfigYaml = preg_replace('~(*ANY)\A\s*\R|\s*(?!\r\n)\s$~mu', '', $acmeConfigYaml);
//
// file_put_contents($masterDomain->domainRoot.'/acme-wildcard-config.yaml', $acmeConfigYaml);
//
// $amePHPPharFile = base_path().'/Modules/LetsEncrypt/Actions/acmephp.phar';
//
// if (!is_dir(dirname($this->installLogFilePath))) {
// shell_exec('mkdir -p ' . dirname($this->installLogFilePath));
// }
//
// //$phyrePHP = ApiClient::getPhyrePHP();
// $phyrePHP = 'phyre-php';
// $command = $phyrePHP.' '.$amePHPPharFile.' run '.$masterDomain->domainRoot.'/acme-wildcard-config.yaml >> ' . $this->installLogFilePath . ' &';
// shell_exec($command);
//
// $validateCertificates = [];
//
// if (! file_exists($sslCertificateFilePath)
// || ! file_exists($sslCertificateKeyFilePath)
// || ! file_exists($sslCertificateChainFilePath)) {
// // Cant get all certificates
// return [
// 'error' => 'Cant get all certificates.'
// ];
// }
//
//
//
// if (! empty($sslCertificateChainFileContent)) {
// $validateCertificates['certificate'] = $sslCertificateFileContent;
// }
// if (! empty($sslCertificateKeyFileContent)) {
// $validateCertificates['private_key'] = $sslCertificateKeyFileContent;
// }
// if (! empty($sslCertificateChainFileContent)) {
// $validateCertificates['certificate_chain'] = $sslCertificateChainFileContent;
// }
// if (count($validateCertificates) !== 3) {
// // Cant get all certificates
// return [
// 'error' => 'Cant get all certificates.'
// ];
// }
//
// $websiteSslCertificate = new DomainSslCertificate();
// $websiteSslCertificate->domain = '*.' . $masterDomain->domain;
// $websiteSslCertificate->certificate = $validateCertificates['certificate'];
// $websiteSslCertificate->private_key = $validateCertificates['private_key'];
// $websiteSslCertificate->certificate_chain = $validateCertificates['certificate_chain'];
// $websiteSslCertificate->customer_id = 0;
// $websiteSslCertificate->is_active = 1;
// $websiteSslCertificate->is_wildcard = 1;
// $websiteSslCertificate->is_auto_renew = 1;
// $websiteSslCertificate->provider = 'letsencrypt';
// $websiteSslCertificate->save();
//
// $mds = new MasterDomain();
// $mds->configureVirtualHost();
//
// ApacheBuild::dispatchSync();
//
// return [
// 'success' => 'SSL certificate installed successfully.'
// ];

if (file_exists($this->installLogFilePath)) {
unlink($this->installLogFilePath);
}

$acmeConfigYaml = view('letsencrypt::actions.acme-config-wildcard-yaml', [
'domain' => $masterDomain->domain,
'domainRoot' => $masterDomain->domainRoot,
'domainPublic' => $masterDomain->domainPublic,
'email' => $masterDomain->email,
'country' => $masterDomain->country,
'locality' => $masterDomain->locality,
'organization' => $masterDomain->organization
])->render();

$acmeConfigYaml = preg_replace('~(*ANY)\A\s*\R|\s*(?!\r\n)\s$~mu', '', $acmeConfigYaml);

file_put_contents($masterDomain->domainRoot.'/acme-wildcard-config.yaml', $acmeConfigYaml);

$amePHPPharFile = base_path().'/Modules/LetsEncrypt/Actions/acmephp.phar';

if (!is_dir(dirname($this->installLogFilePath))) {
shell_exec('mkdir -p ' . dirname($this->installLogFilePath));
}

$phyrePHP = 'phyre-php';
$command = $phyrePHP.' '.$amePHPPharFile.' run '.$masterDomain->domainRoot.'/acme-wildcard-config.yaml >> ' . $this->installLogFilePath . ' &';
shell_exec($command);

return [
'success' => 'SSL certificate request sent.'
];
}

public function getInstallLog()
Expand Down

0 comments on commit 145064f

Please sign in to comment.