Kaynağa Gözat

add the BindFileService

Olivier Massot 3 yıl önce
ebeveyn
işleme
b39da4e4d5
6 değiştirilmiş dosya ile 38 ekleme ve 2 silme
  1. 4 0
      .env
  2. 4 0
      .env.ci
  3. 4 0
      .env.preprod
  4. 4 0
      .env.prod
  5. 4 0
      .env.test
  6. 18 2
      src/Service/Typo3/BindFileService.php

+ 4 - 0
.env

@@ -80,3 +80,7 @@ LOCK_DSN=semaphore
 ###> symfony/mailer ###
 MAILER_DSN=smtp://localhost
 ###< symfony/mailer ###
+
+###> bindfile populate buffer file
+BINDFILE_BUFFER_FILE=/env/subdomain.txt
+###< bindfile populate buffer file

+ 4 - 0
.env.ci

@@ -34,3 +34,7 @@ TYPO3_BASE_URI=http://docker.sub.opentalent.fr
 ###> dolibarr client ###
 DOLIBARR_API_BASE_URI='https://dev-erp.2iopenservice.com/api/index.php/'
 ###< dolibarr client ###
+
+###> bindfile populate buffer file
+BINDFILE_BUFFER_FILE=var/subdomain.txt
+###< bindfile populate buffer file

+ 4 - 0
.env.preprod

@@ -34,3 +34,7 @@ DATABASE_ADMINASSOS_URL=mysql://root:mysql2iopenservice369566@preprod:3306/admin
 ###> dolibarr client ###
 DOLIBARR_API_BASE_URI=https://dev-erp.2iopenservice.com/api/index.php/
 ###< dolibarr client ###
+
+###> bindfile populate buffer file
+BINDFILE_BUFFER_FILE=var/subdomain.txt
+###< bindfile populate buffer file

+ 4 - 0
.env.prod

@@ -30,3 +30,7 @@ TYPO3_BASE_URI=http://ohcluses.opentalent.fr
 ###> AdminAssos configuration ###
 DATABASE_ADMINASSOS_URL=mysql://root:mysql2iopenservice369566@prod-back:3306/adminassos?serverVersion=5.7
 ###< AdminAssos configuration ###
+
+###> bindfile populate buffer file
+BINDFILE_BUFFER_FILE=/env/subdomain.txt
+###< bindfile populate buffer file

+ 4 - 0
.env.test

@@ -11,3 +11,7 @@ TYPO3_BASE_URI=http://test.opentalent.fr/ohcluses
 ###> dolibarr client ###
 DOLIBARR_API_BASE_URI='https://dev-erp.2iopenservice.com/api/index.php/'
 ###< dolibarr client ###
+
+###> bindfile populate buffer file
+BINDFILE_BUFFER_FILE=var/subdomain.txt
+###< bindfile populate buffer file

+ 18 - 2
src/Service/Typo3/BindFileService.php

@@ -4,7 +4,23 @@ namespace App\Service\Typo3;
 
 class BindFileService
 {
-    public function registerSubdomain(string $subdomain) {
-        throw new \RuntimeException('not implemented');
+    public function __construct(
+        private string $bindfileBufferFile
+    ) {}
+
+    /**
+     * Append the subdomain to the buffer file
+     *
+     * A cron consumes this file each 5 minutes to complete the bind file /etc/bind/zones/opentalent.fr.db
+     *
+     * @param string $subdomain
+     */
+    public function registerSubdomain(string $subdomain): void
+    {
+        var_dump($this->bindfileBufferFile);
+        $fsd = @fopen($this->bindfileBufferFile, 'ab+');
+        fwrite($fsd, $subdomain);
+        fwrite($fsd, "\n");
+        fclose($fsd);
     }
 }