Explorar o código

Cambio reale.php

gabriel %!s(int64=7) %!d(string=hai) anos
pai
achega
18ea2be644
Modificáronse 1 ficheiros con 47 adicións e 35 borrados
  1. 47 35
      tools/src/Release.php

+ 47 - 35
tools/src/Release.php

@@ -2,6 +2,7 @@
 
 namespace FD3;
 
+use Docker\Composer\ServiceNotFoundException;
 use function GuzzleHttp\default_user_agent;
 use League\Flysystem\File;
 use Symfony\Component\Console\Command\Command;
@@ -135,14 +136,16 @@ class Release extends Command
                     'VIRTUAL_HOST' => '',
                     'HTTPS_METHOD' => 'nohttps',
                 ),
-                'OAUTH' => false
+                'OAUTH' => false,
+                'MODULE_INSTALL' => false
             ),
             "pma" => array(
                 'HOST_ENV' => true,
                 "VAR_ENV" => array(
                     'VIRTUAL_HOST' => '',
                 ),
-                'OAUTH' => false
+                'OAUTH' => false,
+                'MODULE_INSTALL' => false
             ),
             "extra" => array(
                 'HOST_ENV' => false,
@@ -182,7 +185,7 @@ class Release extends Command
             ->addOption('extra-build', null, InputOption::VALUE_REQUIRED, 'Generate image build', "false")
             ->addOption('host-ip', null, InputOption::VALUE_REQUIRED, 'Ip of the runnning host to be added to the /etc/hosts file, eventually', "127.0.1.1")
             ->addOption('domain', null, InputOption::VALUE_REQUIRED, 'Domain where the flowdat will be installed', "flowdat.com")
-            ->addOption('modules', null, InputOption::VALUE_REQUIRED, 'List of modules to install separated by coma.', "")
+            ->addOption('modules', null, InputOption::VALUE_REQUIRED, 'List of modules to install separated by coma.', "all")
             ->addOption('inventory', null, InputOption::VALUE_REQUIRED, 'Write inventory.ini by default.', true)
             ->addOption('docker-tag', null, InputOption::VALUE_REQUIRED, 'Docker tag to be used', "latest");
     }
@@ -190,7 +193,7 @@ class Release extends Command
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         try {
-            if (!$input->hasOption("modules") && strlen($input->getOption("modules")) == 0) {
+            if (strtolower($input->getOption("modules")) == "all") {
                 // seteo todos los modulos a instalar por defecto
                 $modules = "";
                 foreach ($this->_modules_all as $name => $value) {
@@ -538,21 +541,41 @@ class Release extends Command
 
     function addFreeradius(FileFormat2 $composer, $config = array(), $flavor = "dev")
     {
+        $module = "freeradius";
         $version = "latest";
         $registry = "";
+        $host_env_file = "";
         extract($config);
 
         $composer
             ->addService("freeradius")
             ->image($registry . "fd3/freeradius:" . $version)
             ->addLinks("mysql")
-            ->addEnviroment("MYSQL_ROOT_PASSWORD", $this->_mysql_root_pass)
-            ->addEnviroment("MYSQL_USER", $this->_mysql_user)
-            ->addEnviroment("MYSQL_HOST", "mysql")
-            ->addEnviroment("MYSQL_PASSWORD", $this->_mysql_pass)
-            ->addPorts("1812", "1812/udp")
-            ->addPorts("1813", "1813/udp")
-            ->addPorts("3799", "3799/udp");
+            ->addEnv_file("mysql." . $host_env_file)
+            ->addEnv_file($module . "." . $host_env_file);
+        $this->writeVariablesEnviroment($module . "." . $host_env_file, $module,
+            array(
+                "MYSQL_HOST" => "mysql",
+                "1812" => "1812/udp",
+                "1813" => "1813/udp",
+                "3799" => "3799/udp"));
+    }
+
+    function addPMA(FileFormat2 $composer, $config = array())
+    {
+        $module = "pma";
+        $host_env_file = "";
+        extract($config);
+        if (array_key_exists($module, $this->_modules)) {
+            $composer->addService("phpmyadmin")->image("phpmyadmin/phpmyadmin")
+                ->restart("always")
+                ->addPorts(8080, 80)
+                ->addLinks("mysql", "db")
+                ->addEnv_file("mysql." . $host_env_file)
+                ->addEnv_file($module . "." . $host_env_file);
+
+            $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
+        }
     }
 
     function addGrafana(FileFormat2 $composer, $config = array())
@@ -566,13 +589,11 @@ class Release extends Command
                 ->image("grafana/grafana")
                 ->addLinks("mysql")
                 ->restart("always")
+                ->addEnv_file("mysql.".$host_env_file)
                 ->addVolumes("./statsd/grafana/lib", "/var/lib/grafana");
 
             $this->writeVariablesEnviroment($module . "." . $host_env_file, $module,
                 array(
-//                    "MYSQL_ROOT_PASSWORD" => $this->_mysql_root_pass,
-//                    "MYSQL_USER" => $this->_mysql_user,
-//                    "MYSQL_PASSWORD" => $this->_mysql_pass,
                     "GF_SECURITY_ADMIN_PASSWORD", "queRini6",
                     "GF_INSTALL_PLUGINS", "grafana-simple-json-datasource",
                     "GF_DEFAULT_THEME", "light",
@@ -591,7 +612,7 @@ class Release extends Command
     {
         $version = "latest";
         $registry = "";
-        $mysql_root_pass = "";
+        $host_env_file = "";
         extract($config);
         $composer
             ->addService("statsd")
@@ -618,7 +639,7 @@ class Release extends Command
             ->image($registry . "fd3/jsonep_mysql:$version")
             ->addVolumes("./extra/statsd/endpoint/mysql", "/opt/datasource")
             ->addLinks("mysql")
-            ->addEnviroment("MYSQL_ROOT_PASSWORD", $this->_mysql_root_pass)
+            ->addEnv_file("mysql." . $host_env_file)
             ->restart("always");
 
         $composer
@@ -710,15 +731,12 @@ class Release extends Command
         $this->addFtth($composer, $base_vars);
         $this->addStats($composer, $base_vars);
         $this->addMapas($composer, $base_vars);
+        $this->addCablemodem($composer, $base_vars);
 
         /**************************************************************************************/
         /* Servicios */
         /**************************************************************************************/
-        $this->addMySql($composer, $base_vars + array(
-                'mysql_root_pass' => $this->_mysql_root_pass,
-                'mysql_user' => $this->_mysql_user,
-                'mysql_pass' => $this->_mysql_pass,
-            ));
+        $this->addMySql($composer, $base_vars);
 
         $composer->addService("amqp")->image("rabbitmq:3-management")
             ->restart("always");
@@ -730,11 +748,7 @@ class Release extends Command
         /**************************************************************************************/
         /* Grafana y compoenentes de las estadisticas*/
         /**************************************************************************************/
-        $this->addGrafana($composer, $base_vars + array(
-                'mysql_user' => $this->_mysql_user,
-                'mysql_pass' => $this->_mysql_pass,
-                'mysql_root_pass' => $this->_mysql_root_pass,
-            ));
+        $this->addGrafana($composer, $base_vars);
         $this->addJsonEndPoints($composer, $base_vars);
 
 
@@ -744,14 +758,9 @@ class Release extends Command
         $this->addSupervisord($composer, $base_vars);
         $this->addCommandWorkers($composer, $base_vars);
 
-////        $composer->addService("phpmyadmin")->image("phpmyadmin/phpmyadmin")
-////        	->restart("always")
-////        	->addPorts(8080, 80)
-////        	->addLinks("mysql", "db")
-////        	->addEnviroment("MYSQL_ROOT_PASSWORD", $mysql_root_pass)
-////        	->addEnviroment("VIRTUAL_HOST", "pma.".$fd_domain)
-////        	->addEnviroment("HTTPS_METHOD", 	"nohttps")
-////        ;
+
+        $this->addPMA($composer, $base_vars);
+
         $this->_dObj->file("docker-compose.yml")->content($composer->render());
         // escribo un archivo inventory.ini por defecto para no tener que lanzar los docker
         $this->writeInventory($composer);
@@ -900,7 +909,10 @@ class Release extends Command
     {
         if (isset($this->_modules[$module]['build']) &&
             filter_var($this->_modules[$module]['build'], FILTER_VALIDATE_BOOLEAN)) {
-            $composer->service($module)->build("./$module/");
+            try {
+                $composer->service($module)->build("./$module/");
+            } catch (ServiceNotFoundException $ignore) {
+            }
         }
     }