From 3769ee2a10ec4e58fb42694abdb1aa1b3f2877af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 23 Jan 2024 16:25:11 +0100 Subject: [PATCH] Ensure the certificates generation can be done from everywhere --- .castor/infra.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.castor/infra.php b/.castor/infra.php index 7500295..9fc8d0b 100644 --- a/.castor/infra.php +++ b/.castor/infra.php @@ -104,7 +104,9 @@ function generate_certificates( #[AsOption(description: 'Force the certificates re-generation without confirmation', shortcut: 'f')] bool $force = false, ): void { - if (file_exists(variable('root_dir') . '/infrastructure/docker/services/router/certs/cert.pem') && !$force) { + $sslDir = variable('root_dir') . '/infrastructure/development/services/router/certs'; + + if (file_exists("$sslDir/cert.pem") && !$force) { io()->comment('SSL certificates already exists.'); io()->note('Run "castor infra:generate-certificates --force" to generate new certificates.'); @@ -112,12 +114,12 @@ function generate_certificates( } if ($force) { - if (file_exists($f = variable('root_dir') . '/infrastructure/docker/services/router/certs/cert.pem')) { + if (file_exists($f = "$sslDir/cert.pem")) { io()->comment('Removing existing certificates in infrastructure/docker/services/router/certs/*.pem.'); unlink($f); } - if (file_exists($f = variable('root_dir') . '/infrastructure/docker/services/router/certs/key.pem')) { + if (file_exists($f = "$sslDir/key.pem")) { unlink($f); } } @@ -138,8 +140,8 @@ function generate_certificates( run([ 'mkcert', - '-cert-file', 'infrastructure/docker/services/router/certs/cert.pem', - '-key-file', 'infrastructure/docker/services/router/certs/key.pem', + '-cert-file', "$sslDir/cert.pem", + '-key-file', "$sslDir/key.pem", $rootDomain, "*.{$rootDomain}", ...variable('extra_domains'),