|
@@ -14,6 +14,7 @@ use Symfony\Component\Yaml\Yaml;
|
|
|
|
|
|
class Release extends Command
|
|
|
{
|
|
|
+ private $_running_log;
|
|
|
/**
|
|
|
* @var string Contiene el password del usuario root.
|
|
|
*/
|
|
@@ -38,6 +39,10 @@ class Release extends Command
|
|
|
* @var string Contiene el dominio que se agrega al final de la linea.
|
|
|
*/
|
|
|
private $_domain_behind;
|
|
|
+ /**
|
|
|
+ * @var array Contiene todos los modulos para la instalacion.
|
|
|
+ */
|
|
|
+ private $_modules_all;
|
|
|
/**
|
|
|
* @var array Contiene la configuracion de los modulos.
|
|
|
*/
|
|
@@ -53,11 +58,13 @@ class Release extends Command
|
|
|
public function __construct($name = null)
|
|
|
{
|
|
|
parent::__construct($name);
|
|
|
+ $this->_running_log = "running.log";
|
|
|
$this->_mysql_root_pass = "235r2342gtfsw";
|
|
|
$this->_mysql_user = "iksop";
|
|
|
$this->_mysql_pass = "235r2342gtfsw";
|
|
|
- $this->_domain_behind = "fd3.flowdat.com";
|
|
|
- $this->_modules = array(
|
|
|
+ $this->_domain_behind = "flowdat.com";
|
|
|
+ $this->_modules = array();
|
|
|
+ $this->_modules_all = array(
|
|
|
"base" => array(
|
|
|
'HOST_ENV' => true,
|
|
|
"VAR_ENV" => array(
|
|
@@ -153,13 +160,21 @@ class Release extends Command
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
{
|
|
|
try {
|
|
|
+ if (!$input->hasOption("modules")) {
|
|
|
+ $input->setOption("modules", implode(",", array_keys($this->_modules_all)));
|
|
|
+ }
|
|
|
+ //##############################################
|
|
|
+ // TODO: quitar este linea
|
|
|
+ $input->setOption("modules", "base,ftth,extra");
|
|
|
+ //##############################################
|
|
|
+ $this->AddModules(explode(",", $input->getOption("modules")));
|
|
|
$dir = $input->getArgument('dir');
|
|
|
if (!is_dir($dir)) {
|
|
|
mkdir($dir, 0777, true);
|
|
|
}
|
|
|
- if (file_exists($dir . "/running.log")) {
|
|
|
+ if (file_exists($dir . "/" . $this->_running_log)) {
|
|
|
$helper = $this->getHelper('question');
|
|
|
- $question = new ConfirmationQuestion('The running.log file exist. Read file or take parameters? (Y/n)', true);
|
|
|
+ $question = new ConfirmationQuestion('The ' . $this->_running_log . ' file exist. Read file or take parameters? (Y/n)', true);
|
|
|
if ($helper->ask($input, $output, $question)) {
|
|
|
$this->setParametersFormFile($input);
|
|
|
}
|
|
@@ -241,18 +256,20 @@ class Release extends Command
|
|
|
$registry = "";
|
|
|
$host_env_file = "";
|
|
|
extract($config);
|
|
|
- $composer
|
|
|
- ->addService($module)
|
|
|
- ->image($registry . "fd3/$module:" . $version)
|
|
|
- ->restart("always")
|
|
|
- ->addLinks("mysql:mysql")
|
|
|
- ->addLinks("amqp")
|
|
|
- ->addEnv_file($host_env_file)
|
|
|
- ->addEnv_file($module . "." . $host_env_file)
|
|
|
- ->addVolumes("./$module/", "/opt/$module");
|
|
|
- $this->addBuild($module, $composer);
|
|
|
-
|
|
|
- $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ if (array_key_exists($module, $this->_modules)) {
|
|
|
+ $composer
|
|
|
+ ->addService($module)
|
|
|
+ ->image($registry . "fd3/$module:" . $version)
|
|
|
+ ->restart("always")
|
|
|
+ ->addLinks("mysql:mysql")
|
|
|
+ ->addLinks("amqp")
|
|
|
+ ->addEnv_file($host_env_file)
|
|
|
+ ->addEnv_file($module . "." . $host_env_file)
|
|
|
+ ->addVolumes("./$module/", "/opt/$module");
|
|
|
+ $this->addBuild($module, $composer);
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function addFtth(FileFormat2 $composer, $config = array())
|
|
@@ -262,22 +279,23 @@ class Release extends Command
|
|
|
$registry = "";
|
|
|
$host_env_file = "";
|
|
|
extract($config);
|
|
|
-
|
|
|
- $composer
|
|
|
- ->addService($module)
|
|
|
- ->image($registry . "fd3/$module:" . $version)
|
|
|
- ->restart("always")
|
|
|
- ->addLinks("mysql:mysql")
|
|
|
- ->addLinks("base")
|
|
|
- ->addLinks("amqp")
|
|
|
- ->addLinks("base", $this->getDomain("base"))
|
|
|
- ->addEnv_file($host_env_file)
|
|
|
- ->addEnv_file($module . "." . $host_env_file)
|
|
|
- ->addEnv_file($module . ".oauth.env")
|
|
|
- ->addVolumes("./$module/", "/opt/" . $module);
|
|
|
- $this->addBuild($module, $composer);
|
|
|
-
|
|
|
- $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ if (array_key_exists($module, $this->_modules)) {
|
|
|
+ $composer
|
|
|
+ ->addService($module)
|
|
|
+ ->image($registry . "fd3/$module:" . $version)
|
|
|
+ ->restart("always")
|
|
|
+ ->addLinks("mysql:mysql")
|
|
|
+ ->addLinks("base")
|
|
|
+ ->addLinks("amqp")
|
|
|
+ ->addLinks("base", $this->getDomain("base"))
|
|
|
+ ->addEnv_file($host_env_file)
|
|
|
+ ->addEnv_file($module . "." . $host_env_file)
|
|
|
+ ->addEnv_file($module . ".oauth.env")
|
|
|
+ ->addVolumes("./$module/", "/opt/" . $module);
|
|
|
+ $this->addBuild($module, $composer);
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function addStats(FileFormat2 $composer, $config = array())
|
|
@@ -287,23 +305,24 @@ class Release extends Command
|
|
|
$registry = "";
|
|
|
$host_env_file = "";
|
|
|
extract($config);
|
|
|
-
|
|
|
- $composer
|
|
|
- ->addService($module)
|
|
|
- ->image($registry . "fd3/$module:" . $version)
|
|
|
- ->addLinks("mysql:mysql")
|
|
|
- ->addLinks("base")
|
|
|
- ->addLinks("amqp")
|
|
|
- ->addLinks("base", $this->getDomain("base"))
|
|
|
- //->addLinks("jsendpoint", "endpoint")
|
|
|
- //->addLinks("statsd", "statsd")
|
|
|
- ->addVolumes("./$module/", "/opt/$module")
|
|
|
- ->addEnv_file($host_env_file)
|
|
|
- ->addEnv_file($module . "." . $host_env_file)
|
|
|
- ->addEnv_file("$module.oauth.env");
|
|
|
- $this->addBuild($module, $composer);
|
|
|
-
|
|
|
- $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ if (array_key_exists($module, $this->_modules)) {
|
|
|
+ $composer
|
|
|
+ ->addService($module)
|
|
|
+ ->image($registry . "fd3/$module:" . $version)
|
|
|
+ ->addLinks("mysql:mysql")
|
|
|
+ ->addLinks("base")
|
|
|
+ ->addLinks("amqp")
|
|
|
+ ->addLinks("base", $this->getDomain("base"))
|
|
|
+ //->addLinks("jsendpoint", "endpoint")
|
|
|
+ //->addLinks("statsd", "statsd")
|
|
|
+ ->addVolumes("./$module/", "/opt/$module")
|
|
|
+ ->addEnv_file($host_env_file)
|
|
|
+ ->addEnv_file($module . "." . $host_env_file)
|
|
|
+ ->addEnv_file("$module.oauth.env");
|
|
|
+ $this->addBuild($module, $composer);
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function addMapas(FileFormat2 $composer, $config = array())
|
|
@@ -313,22 +332,23 @@ class Release extends Command
|
|
|
$registry = "";
|
|
|
$host_env_file = "";
|
|
|
extract($config);
|
|
|
-
|
|
|
- $composer
|
|
|
- ->addService($module)
|
|
|
- ->image($registry . "fd3/$module:" . $version)
|
|
|
- ->addLinks("mysql:mysql")
|
|
|
- ->addLinks("base")
|
|
|
- ->addLinks("amqp")
|
|
|
- ->addLinks("base", $this->getDomain("base"))
|
|
|
- ->addEnv_file($host_env_file)
|
|
|
- ->addEnv_file($module . "." . $host_env_file)
|
|
|
- ->addEnv_file("$module.oauth.env")
|
|
|
- ->addVolumes("./$module/", "/opt/$module")
|
|
|
- ->addVolumes("./$module/web/uploads", "/opt/$module/web/uploads");
|
|
|
- $this->addBuild($module, $composer);
|
|
|
-
|
|
|
- $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ if (array_key_exists($module, $this->_modules)) {
|
|
|
+ $composer
|
|
|
+ ->addService($module)
|
|
|
+ ->image($registry . "fd3/$module:" . $version)
|
|
|
+ ->addLinks("mysql:mysql")
|
|
|
+ ->addLinks("base")
|
|
|
+ ->addLinks("amqp")
|
|
|
+ ->addLinks("base", $this->getDomain("base"))
|
|
|
+ ->addEnv_file($host_env_file)
|
|
|
+ ->addEnv_file($module . "." . $host_env_file)
|
|
|
+ ->addEnv_file("$module.oauth.env")
|
|
|
+ ->addVolumes("./$module/", "/opt/$module")
|
|
|
+ ->addVolumes("./$module/web/uploads", "/opt/$module/web/uploads");
|
|
|
+ $this->addBuild($module, $composer);
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function addNginx(FileFormat2 $composer, $config = array())
|
|
@@ -409,28 +429,33 @@ class Release extends Command
|
|
|
$module = "grafana";
|
|
|
$host_env_file = "";
|
|
|
extract($config);
|
|
|
-
|
|
|
- $composer
|
|
|
- ->addService($module)
|
|
|
- ->image("grafana/grafana")
|
|
|
- ->addLinks("mysql")
|
|
|
- ->restart("always")
|
|
|
- ->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",
|
|
|
- "GF_AUTH_ANONYMOUS_ORG_NAME" => "Main Org.",
|
|
|
- "GF_AUTH_ANONYMOUS_ORG_ROLE" => "Viewer",
|
|
|
- "GF_AUTH_ANONYMOUS_ENABLED" => "true",
|
|
|
- "GF_DATABASE_URL" => "mysql://root:" . $this->_mysql_root_pass . "@mysql:3306/grafana",
|
|
|
- "GF_SERVER_ROOT_URL" => "http://" . $this->getDomain("grafana") . "/"
|
|
|
- ));
|
|
|
+ if (array_key_exists($module, $this->_modules)) {
|
|
|
+ $composer
|
|
|
+ ->addService($module)
|
|
|
+ ->image("grafana/grafana")
|
|
|
+ ->addLinks("mysql")
|
|
|
+ ->restart("always")
|
|
|
+ ->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",
|
|
|
+ "GF_AUTH_ANONYMOUS_ORG_NAME" => "Main Org.",
|
|
|
+ "GF_AUTH_ANONYMOUS_ORG_ROLE" => "Viewer",
|
|
|
+ "GF_AUTH_ANONYMOUS_ENABLED" => "true",
|
|
|
+ "GF_DATABASE_URL" => "mysql://root:" . $this->_mysql_root_pass . "@mysql:3306/grafana",
|
|
|
+ "GF_SERVER_ROOT_URL" => "http://" . $this->getDomain("grafana") . "/"
|
|
|
+ ));
|
|
|
+
|
|
|
+ $this->addJsonEndPoints($composer, $config + array(
|
|
|
+ 'mysql_root_pass' => $this->_mysql_root_pass,
|
|
|
+ ));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function addJsonEndPoints(FileFormat2 $composer, $config = array())
|
|
@@ -439,7 +464,6 @@ class Release extends Command
|
|
|
$registry = "";
|
|
|
$mysql_root_pass = "";
|
|
|
extract($config);
|
|
|
-
|
|
|
$composer
|
|
|
->addService("statsd")
|
|
|
->build("./extra/statsd/statsd")
|
|
@@ -575,24 +599,21 @@ class Release extends Command
|
|
|
'mysql_pass' => $this->_mysql_pass,
|
|
|
'mysql_root_pass' => $this->_mysql_root_pass,
|
|
|
));
|
|
|
- $this->addJsonEndPoints($composer, $base_vars + array(
|
|
|
- 'mysql_root_pass' => $this->_mysql_root_pass,
|
|
|
- ));
|
|
|
|
|
|
/**************************************************************************************/
|
|
|
/* Workers */
|
|
|
/**************************************************************************************/
|
|
|
- $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->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->_dObj->file("docker-compose.yml")->content($composer->render());
|
|
|
}
|
|
|
|
|
@@ -643,7 +664,7 @@ class Release extends Command
|
|
|
$file ["Running"] = array("date" => gmdate('Y-m-d h:i:s'));
|
|
|
$file ["Arguments"] = $input->getArguments();
|
|
|
$file ["Options"] = $input->getOptions();
|
|
|
- $this->_dObj->file("running.log")->writeIniConfig($file);
|
|
|
+ $this->_dObj->file($this->_running_log)->writeIniConfig($file);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -749,7 +770,7 @@ class Release extends Command
|
|
|
*/
|
|
|
private function setParametersFormFile(InputInterface $input)
|
|
|
{
|
|
|
- $parameters = parse_ini_file($input->getArgument('dir') . "/running.log", true);
|
|
|
+ $parameters = parse_ini_file($input->getArgument('dir') . "/" . $this->_running_log, true);
|
|
|
foreach ($parameters["Options"] as $key => $value) {
|
|
|
$input->setOption($key, $value);
|
|
|
}
|
|
@@ -763,4 +784,16 @@ class Release extends Command
|
|
|
{
|
|
|
return $module . "." . $this->_domain . "." . $this->_domain_behind;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param array $modules Contiene los modulos a implementar
|
|
|
+ */
|
|
|
+ private function AddModules($modules)
|
|
|
+ {
|
|
|
+ foreach ($modules as $value) {
|
|
|
+ if (array_key_exists($value, $this->_modules_all)) {
|
|
|
+ $this->_modules[$value] = $this->_modules_all[$value];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|