1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 07:34:03 +00:00

Add vhost_is_written test

This commit is contained in:
Samuel Štancl 2019-02-02 16:24:36 +01:00
parent 094dc924e4
commit 2a33d0ec85
7 changed files with 105 additions and 7 deletions

View file

@ -2,8 +2,37 @@
namespace Stancl\Tenancy\ServerConfigManagers;
use Symfony\Component\Process\Process;
use Stancl\Tenancy\Interfaces\ServerConfigManager;
class NginxConfigManager implements ServerConfigManager
{
public function addVhost(string $domain, string $file): bool
{
$f = fopen($file, 'a');
fwrite($f, $this->getVhostText($domain));
fclose($f);
return true;
}
public function getVhostText(string $domain)
{
return str_replace('%host%', $domain, config('tenancy.server.nginx.vhost'));
}
public function deployCertificate(string $domain): bool
{
$process = new Process(array_merge([
config('tenancy.server.certbot_path'),
'-n',
'--nginx',
'--agree-tos',
'-d', $domain,
'--preferred-challenges', 'http',
], config('tenancy.server.nginx.extra_certbot_args')));
$process->run();
return $process->isSuccessful();
}
}