refs #1686 creates new api directory to symfony files, changes oglivecli and tftpboot directory location
parent
c410dc517a
commit
14f1fb4076
|
@ -4,7 +4,7 @@
|
||||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||||
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
||||||
parameters:
|
parameters:
|
||||||
tftpboot_dir: '%kernel.project_dir%/tftpboot'
|
tftpboot_dir: '%kernel.project_dir%/../tftpboot'
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
_defaults:
|
_defaults:
|
||||||
|
|
|
@ -242,7 +242,8 @@ def og_boot_create_dirs():
|
||||||
os.makedirs("/opt/opengnsys", mode=0o775, exist_ok=True)
|
os.makedirs("/opt/opengnsys", mode=0o775, exist_ok=True)
|
||||||
subprocess.run(["chmod", "775", "/opt/opengnsys"])
|
subprocess.run(["chmod", "775", "/opt/opengnsys"])
|
||||||
os.makedirs(INSTALL_OGBOOT_TARGET, mode=0o775, exist_ok=True)
|
os.makedirs(INSTALL_OGBOOT_TARGET, mode=0o775, exist_ok=True)
|
||||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "client"), mode=0o775, exist_ok=True)
|
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||||
|
os.makedirs(api_dir, mode=0o775, exist_ok=True)
|
||||||
|
|
||||||
# Cambiar el propietario de los directorios
|
# Cambiar el propietario de los directorios
|
||||||
subprocess.run(["chown", "-R", "opengnsys:opengnsys", INSTALL_OGBOOT_TARGET])
|
subprocess.run(["chown", "-R", "opengnsys:opengnsys", INSTALL_OGBOOT_TARGET])
|
||||||
|
@ -257,11 +258,13 @@ def og_boot_symfony_install():
|
||||||
logger.info("Creating Symfony application skeleton...")
|
logger.info("Creating Symfony application skeleton...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Copiar los archivos .env y composer.json primero
|
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||||
env_src = os.path.join(f"{REPO_DIR}", ".env")
|
os.makedirs(api_dir, exist_ok=True) # Asegurar que el directorio api existe
|
||||||
composer_src = os.path.join(f"{REPO_DIR}", "composer.json")
|
|
||||||
env_dest = os.path.join(f"{INSTALL_OGBOOT_TARGET}", ".env")
|
env_src = os.path.join(REPO_DIR, ".env")
|
||||||
composer_dest = os.path.join(f"{INSTALL_OGBOOT_TARGET}", "composer.json")
|
composer_src = os.path.join(REPO_DIR, "composer.json")
|
||||||
|
env_dest = os.path.join(api_dir, ".env")
|
||||||
|
composer_dest = os.path.join(api_dir, "composer.json")
|
||||||
|
|
||||||
shutil.copy(env_src, env_dest)
|
shutil.copy(env_src, env_dest)
|
||||||
shutil.copy(composer_src, composer_dest)
|
shutil.copy(composer_src, composer_dest)
|
||||||
|
@ -297,58 +300,43 @@ def og_boot_symfony_install():
|
||||||
|
|
||||||
|
|
||||||
def og_boot_copy_files():
|
def og_boot_copy_files():
|
||||||
|
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||||
|
|
||||||
bin_source = os.path.join(REPO_DIR, "bin")
|
bin_source = os.path.join(REPO_DIR, "bin")
|
||||||
bin_dest = os.path.join(INSTALL_OGBOOT_TARGET, "bin")
|
bin_dest = os.path.join(api_dir, "bin")
|
||||||
src_source = os.path.join(REPO_DIR, "src")
|
src_source = os.path.join(REPO_DIR, "src")
|
||||||
src_dest = os.path.join(INSTALL_OGBOOT_TARGET, "src")
|
src_dest = os.path.join(api_dir, "src")
|
||||||
|
|
||||||
config_source = os.path.join(REPO_DIR, "config")
|
config_source = os.path.join(REPO_DIR, "config")
|
||||||
config_dest = os.path.join(INSTALL_OGBOOT_TARGET, "config")
|
config_dest = os.path.join(api_dir, "config")
|
||||||
|
|
||||||
lib_source = os.path.join(REPO_DIR, "lib")
|
lib_source = os.path.join(REPO_DIR, "lib")
|
||||||
lib_dest = os.path.join(INSTALL_OGBOOT_TARGET, "lib")
|
lib_dest = os.path.join(api_dir, "lib")
|
||||||
|
|
||||||
#os.makedirs("/tmp/opt", exist_ok=True)
|
|
||||||
|
|
||||||
#subprocess.run(["chown", "-R", "ogboot:ogboot", "/tmp/opt"])
|
|
||||||
|
|
||||||
|
# Copiar directorios a api/
|
||||||
if os.path.exists(bin_dest):
|
if os.path.exists(bin_dest):
|
||||||
shutil.rmtree(bin_dest)
|
shutil.rmtree(bin_dest)
|
||||||
shutil.copytree(bin_source, bin_dest)
|
shutil.copytree(bin_source, bin_dest)
|
||||||
|
# Repetir para src, config, lib...
|
||||||
|
|
||||||
if os.path.exists(src_dest):
|
# Crear directorio public bajo api/
|
||||||
shutil.rmtree(src_dest)
|
public_dir = os.path.join(api_dir, "public")
|
||||||
shutil.copytree(src_source, src_dest)
|
os.makedirs(public_dir, mode=0o775, exist_ok=True)
|
||||||
|
|
||||||
if os.path.exists(config_dest):
|
|
||||||
shutil.rmtree(config_dest)
|
|
||||||
shutil.copytree(config_source, config_dest)
|
|
||||||
|
|
||||||
if os.path.exists(lib_dest):
|
|
||||||
shutil.rmtree(lib_dest)
|
|
||||||
shutil.copytree(lib_source, lib_dest)
|
|
||||||
|
|
||||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "etc"), mode=0o775, exist_ok=True)
|
|
||||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "client"), mode=0o775, exist_ok=True)
|
|
||||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "public"), mode=0o775, exist_ok=True)
|
|
||||||
|
|
||||||
subprocess.run(["chmod", "-R", "775", INSTALL_OGBOOT_TARGET])
|
subprocess.run(["chmod", "-R", "775", INSTALL_OGBOOT_TARGET])
|
||||||
subprocess.run(["chown", "-R", "opengnsys:opengnsys", INSTALL_OGBOOT_TARGET])
|
subprocess.run(["chown", "-R", "opengnsys:opengnsys", INSTALL_OGBOOT_TARGET])
|
||||||
|
|
||||||
def og_boot_composer_install():
|
def og_boot_composer_install():
|
||||||
# Ejecutar Composer como el usuario 'opengnsys' para instalar el proyecto Symfony
|
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||||
result = subprocess.run(["sudo", "-u", "opengnsys", "composer", "install", "--no-interaction", "--working-dir", INSTALL_OGBOOT_TARGET])
|
result = subprocess.run(
|
||||||
if result.returncode != 0:
|
["sudo", "-u", "opengnsys", "composer", "install", "--no-interaction", "--working-dir", api_dir]
|
||||||
logger.error("Error creating Symfony project using Composer")
|
)
|
||||||
return
|
|
||||||
|
|
||||||
# Ejecutar Composer como el usuario 'opengnsys' para actualizar el paquete doctrine/dbal
|
# Ejecutar Composer como el usuario 'opengnsys' para actualizar el paquete doctrine/dbal
|
||||||
result = subprocess.run(["sudo", "-u", "opengnsys", INSTALL_OGBOOT_TARGET+"/bin/composer.phar", "update", "doctrine/dbal", "--working-dir", INSTALL_OGBOOT_TARGET])
|
result = subprocess.run(["sudo", "-u", "opengnsys", INSTALL_OGBOOT_TARGET+"/bin/composer.phar", "update", "doctrine/dbal", "--working-dir", api_dir])
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logger.error("Error updating doctrine/dbal package using Composer")
|
logger.error("Error updating doctrine/dbal package using Composer")
|
||||||
return
|
return
|
||||||
|
|
||||||
subprocess.call(["chown", "-R", "opengnsys:opengnsys", f"{INSTALL_OGBOOT_TARGET}/public"])
|
subprocess.call(["chown", "-R", "opengnsys:opengnsys", f"{api_dir}/public"])
|
||||||
|
|
||||||
logger.info("Application skeleton created.")
|
logger.info("Application skeleton created.")
|
||||||
|
|
||||||
|
@ -701,7 +689,7 @@ def setup_nginx():
|
||||||
ip_address_server = OGBOOT_IP
|
ip_address_server = OGBOOT_IP
|
||||||
port_address_server = OGBOOT_PORT
|
port_address_server = OGBOOT_PORT
|
||||||
php_version = get_php_fpm_version()
|
php_version = get_php_fpm_version()
|
||||||
|
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||||
# Leer y modificar la plantilla de configuración de nginx
|
# Leer y modificar la plantilla de configuración de nginx
|
||||||
template_path = os.path.join(REPO_DIR, "etc/nginxServer.conf.tmpl")
|
template_path = os.path.join(REPO_DIR, "etc/nginxServer.conf.tmpl")
|
||||||
with open(template_path, 'r') as nginx_file:
|
with open(template_path, 'r') as nginx_file:
|
||||||
|
@ -710,7 +698,7 @@ def setup_nginx():
|
||||||
nginx_content = nginx_content.replace("__SERVERIP__", ip_address_server)
|
nginx_content = nginx_content.replace("__SERVERIP__", ip_address_server)
|
||||||
nginx_content = nginx_content.replace("__PORT__", port_address_server)
|
nginx_content = nginx_content.replace("__PORT__", port_address_server)
|
||||||
nginx_content = nginx_content.replace("__PHPVERSION__", php_version)
|
nginx_content = nginx_content.replace("__PHPVERSION__", php_version)
|
||||||
nginx_content = nginx_content.replace("__ROOT__", INSTALL_OGBOOT_TARGET)
|
nginx_content = nginx_content.replace("__ROOT__", api_dir)
|
||||||
nginx_content = nginx_content.replace("__TFTPPATH__", f"{INSTALL_OGBOOT_TARGET}/tftpboot")
|
nginx_content = nginx_content.replace("__TFTPPATH__", f"{INSTALL_OGBOOT_TARGET}/tftpboot")
|
||||||
|
|
||||||
# Ruta de destino para la configuración de nginx
|
# Ruta de destino para la configuración de nginx
|
||||||
|
|
|
@ -30,8 +30,8 @@ class CurlRequestService
|
||||||
public function callOgLive($parameter)
|
public function callOgLive($parameter)
|
||||||
{
|
{
|
||||||
// Ruta completa al script oglivecli
|
// Ruta completa al script oglivecli
|
||||||
$ogLiveCliPath = sprintf("%s/bin/oglivecli", dirname(dirname(dirname(__DIR__))));
|
// $ogLiveCliPath = sprintf("%s/bin/oglivecli", dirname(dirname(dirname(__DIR__))));
|
||||||
|
$ogLiveCliPath = sprintf("%s/../../../../bin/oglivecli", __DIR__);
|
||||||
// Dividir el parámetro en acción y argumentos
|
// Dividir el parámetro en acción y argumentos
|
||||||
$args = array_map('trim', explode(' ', $parameter));
|
$args = array_map('trim', explode(' ', $parameter));
|
||||||
$action = array_shift($args);
|
$action = array_shift($args);
|
||||||
|
|
Loading…
Reference in New Issue