Refs #202 fix issue
parent
957a343fea
commit
f3435f1f96
|
@ -11,23 +11,25 @@ import platform, os, sys, subprocess, datetime, shutil, pwd, glob, zipfile, urll
|
|||
# subprocess.run(['source', '~/.bashrc'], shell=True)
|
||||
|
||||
# Leer variables de entorno
|
||||
env_ogCore_ServerIP = os.getenv('OGCORE_SERVER_IP') #"172.17.8.82"
|
||||
env_ogCore_Server = os.getenv('OGCORE_SERVER') #"opengnsys.es"
|
||||
env_ogCore_Dir = os.getenv('OGCORE_DIR') #{INSTALL_OPENGNSYS_TARGET}
|
||||
env_ogBoot_Dir = os.getenv('OGBOOT_DIR') #{INSTALL_OGBOOT_TARGET}
|
||||
env_ogBoot_GitRepo = os.getenv('OGBOOT_GIT_REPO') #"ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git"
|
||||
#env_ogCore_ServerIP = "172.17.8.82" #os.getenv('OGCORE_SERVER_IP') #"172.17.8.82"
|
||||
#env_ogCore_Server = "opengnsys.es" #os.getenv('OGCORE_SERVER') #"opengnsys.es"
|
||||
#env_ogCore_Dir = "/opt/opengnsys" #os.getenv('OGCORE_DIR') #{INSTALL_OPENGNSYS_TARGET}
|
||||
#env_ogBoot_Dir = "/opt/ogboot" #os.getenv('OGBOOT_DIR') #{INSTALL_OGBOOT_TARGET}
|
||||
#env_ogBoot_GitRepo = "ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git" #os.getenv('OGBOOT_GIT_REPO') #"ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git"
|
||||
#env_ogCore_ServerIP = os.getenv('OGCORE_SERVER_IP') #"172.17.8.82"
|
||||
#env_ogCore_Server = os.getenv('OGCORE_SERVER') #"opengnsys.es"
|
||||
#env_ogCore_Dir = os.getenv('OGCORE_DIR') #{INSTALL_OPENGNSYS_TARGET}
|
||||
#env_ogBoot_Dir = os.getenv('OGBOOT_DIR') #{INSTALL_OGBOOT_TARGET}
|
||||
#env_ogBoot_GitRepo = os.getenv('OGBOOT_GIT_REPO') #"ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git"
|
||||
|
||||
# Constantes, ambiente de desarrollo
|
||||
env_ogCore_ServerIP = "172.17.8.82"
|
||||
env_ogCore_Server = "opengnsys.es"
|
||||
env_ogCore_Dir = "/opt/opengnsys"
|
||||
env_ogBoot_Dir = "/opt/ogboot"
|
||||
env_ogBoot_GitRepo = "ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git"
|
||||
|
||||
PROGRAM = os.path.splitext(os.path.basename(sys.argv[0]))[0]
|
||||
PROGRAM_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||
PROGRAM_NAME = os.path.basename(sys.argv[0])
|
||||
|
||||
SERVER_OPENGNSYS = f"{env_ogCore_ServerIP}"
|
||||
OPENGNSYS_SERVER = f"{env_ogCore_Server}"
|
||||
OGCORE_IP = f"{env_ogCore_ServerIP}"
|
||||
OGCORE_SERVER = f"{env_ogCore_Server}"
|
||||
INSTALL_TARGET = f"{env_ogBoot_Dir}"
|
||||
INSTALL_OPENGNSYS_TARGET = f"{env_ogCore_Dir}"
|
||||
INSTALL_OGBOOT_TARGET = f"{env_ogBoot_Dir}"
|
||||
|
@ -306,16 +308,16 @@ def og_boot_create_dirs():
|
|||
logger.error("Error while creating directory paths!")
|
||||
exit(1)
|
||||
|
||||
def og_boot_symfony_install(path_opengnsys_base):
|
||||
global WORKDIR
|
||||
def og_boot_symfony_install():
|
||||
global WORKDIR, INSTALL_OGBOOT_TARGET
|
||||
logger.info("Creating Symfony application skeleton...")
|
||||
|
||||
try:
|
||||
# Copiar los archivos .env y composer.json primero
|
||||
env_src = os.path.join(WORKDIR, "ogboot/.env")
|
||||
composer_src = os.path.join(WORKDIR, "ogboot/composer.json")
|
||||
env_dest = os.path.join(path_opengnsys_base, ".env")
|
||||
composer_dest = os.path.join(path_opengnsys_base, "composer.json")
|
||||
env_src = os.path.join(f"{WORKDIR}", "ogboot/.env")
|
||||
composer_src = os.path.join(f"{WORKDIR}", "ogboot/composer.json")
|
||||
env_dest = os.path.join(f"{INSTALL_OGBOOT_TARGET}", ".env")
|
||||
composer_dest = os.path.join(f"{INSTALL_OGBOOT_TARGET}", "composer.json")
|
||||
|
||||
shutil.copy(env_src, env_dest)
|
||||
shutil.copy(composer_src, composer_dest)
|
||||
|
@ -329,23 +331,23 @@ def og_boot_symfony_install(path_opengnsys_base):
|
|||
shutil.chown(composer_dest, user='ogboot', group='ogboot')
|
||||
logger.info(f"Set permissions and owner for {env_dest} and {composer_dest}")
|
||||
|
||||
logger.info(f".env and composer.json files copied to {path_opengnsys_base}")
|
||||
logger.info(f".env and composer.json files copied to {INSTALL_OGBOOT_TARGET}")
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred while copying files: {e}")
|
||||
raise
|
||||
|
||||
def og_boot_copy_files(path_opengnsys_base):
|
||||
def og_boot_copy_files():
|
||||
global INSTALL_TARGET, WORKDIR
|
||||
bin_source = os.path.join(WORKDIR, "ogboot/bin")
|
||||
bin_dest = os.path.join(path_opengnsys_base, "bin")
|
||||
bin_dest = os.path.join(INSTALL_OGBOOT_TARGET, "bin")
|
||||
src_source = os.path.join(WORKDIR, "ogboot/src")
|
||||
src_dest = os.path.join(path_opengnsys_base, "src")
|
||||
src_dest = os.path.join(INSTALL_OGBOOT_TARGET, "src")
|
||||
|
||||
config_source = os.path.join(WORKDIR, "ogboot/config")
|
||||
config_dest = os.path.join(path_opengnsys_base, "config")
|
||||
config_dest = os.path.join(INSTALL_OGBOOT_TARGET, "config")
|
||||
|
||||
lib_source = os.path.join(WORKDIR, "ogboot/lib")
|
||||
lib_dest = os.path.join(path_opengnsys_base, "lib")
|
||||
lib_dest = os.path.join(INSTALL_OGBOOT_TARGET, "lib")
|
||||
|
||||
if os.path.exists(bin_dest):
|
||||
shutil.rmtree(bin_dest)
|
||||
|
@ -367,18 +369,18 @@ def og_boot_copy_files(path_opengnsys_base):
|
|||
os.makedirs(os.path.join(INSTALL_TARGET, "client"), mode=0o750, exist_ok=True)
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "public"), mode=0o750, exist_ok=True)
|
||||
|
||||
subprocess.run(["sudo", "chmod", "-R", "755", path_opengnsys_base])
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", path_opengnsys_base])
|
||||
subprocess.run(["sudo", "chmod", "-R", "755", INSTALL_OGBOOT_TARGET])
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", INSTALL_OGBOOT_TARGET])
|
||||
|
||||
def og_boot_composer_install(path_opengnsys_base):
|
||||
def og_boot_composer_install():
|
||||
# Ejecutar Composer como el usuario 'ogboot' para instalar el proyecto Symfony
|
||||
result = subprocess.run(["sudo", "-u", "ogboot", "/opt/ogboot/bin/composer.phar", "install", "--no-interaction", "--working-dir", path_opengnsys_base])
|
||||
result = subprocess.run(["sudo", "-u", "ogboot", "/opt/ogboot/bin/composer.phar", "install", "--no-interaction", "--working-dir", INSTALL_OGBOOT_TARGET])
|
||||
if result.returncode != 0:
|
||||
logger.error("Error creating Symfony project using Composer")
|
||||
return
|
||||
|
||||
# Eliminar composer.lock si existe
|
||||
composer_lock_path = os.path.join(path_opengnsys_base, "composer.lock")
|
||||
composer_lock_path = os.path.join(INSTALL_OGBOOT_TARGET, "composer.lock")
|
||||
if os.path.exists(composer_lock_path):
|
||||
os.remove(composer_lock_path)
|
||||
|
||||
|
@ -730,14 +732,14 @@ def getNetworkSettings():
|
|||
return (0)
|
||||
|
||||
def openGnsysConfigure():
|
||||
global DEFAULTDEV, INSTALL_TARGET, SERVER_OPENGNSYS, WORKDIR
|
||||
global DEFAULTDEV, INSTALL_TARGET, OGCORE_IP, WORKDIR
|
||||
i = 0
|
||||
dev = ""
|
||||
CONSOLEURL = ""
|
||||
CONSOLEURL = f"https://{SERVER_OPENGNSYS}/opengnsys"
|
||||
CONSOLEURL = f"https://{OGCORE_IP}/opengnsys"
|
||||
with open(f"{WORKDIR}/ogboot/etc/ogAdmClient.cfg") as file:
|
||||
content = file.read()
|
||||
content = content.replace("SERVERIP", SERVER_OPENGNSYS)
|
||||
content = content.replace("SERVERIP", OGCORE_IP)
|
||||
content = content.replace("OPENGNSYSURL", CONSOLEURL)
|
||||
with open(f"{INSTALL_TARGET}/client/etc/ogAdmClient-{DEFAULTDEV}.cfg", "w") as outfile:
|
||||
outfile.write(content)
|
||||
|
@ -754,15 +756,17 @@ def mount_NFS():
|
|||
else:
|
||||
logger.error("Could not mount the NFS system.")
|
||||
exit(1)
|
||||
logger.info("copying tftp and ipxe files")
|
||||
logger.info("copying tftpboot files")
|
||||
#subprocess.call(["ls", "/mnt/"])
|
||||
subprocess.call(["sudo", "cp", "-r", "/mnt/srv/artefactos/ogboot/tftpboot/", "/tmp"])
|
||||
if not os.path.exists(IPXE_DIR + "/tftpboot"):
|
||||
os.makedirs(IPXE_DIR + "/tftpboot")
|
||||
#os.chdir(f"{IPXE_DIR}/tftpboot")
|
||||
logger.info("copying ipxe files")
|
||||
subprocess.call(["sudo", "cp", "-r", "/mnt/srv/artefactos/ogboot/ipxe/", "/tmp"])
|
||||
if not os.path.exists(IPXE_DIR + "/src"):
|
||||
os.makedirs(IPXE_DIR + "/src")
|
||||
logger.info(f"make to {IPXE_DIR}/src")
|
||||
os.chdir(f"{IPXE_DIR}/src")
|
||||
if subprocess.call(["sudo", "make", "-s", "-j", "4"]) == 0:
|
||||
logger.info(f"Directory {IPXE_DIR}/src correctly mounted.")
|
||||
|
@ -1000,6 +1004,15 @@ def install_oglive_daemon():
|
|||
###############################################################################
|
||||
|
||||
logger.info(f"Starting installation of ogBoot.")
|
||||
|
||||
logger.info("Variables de entorno")
|
||||
logger.info(f"OGCORE_IP:{env_ogCore_ServerIP}:{OGCORE_IP}")
|
||||
logger.info(f"OGCORE_SERVER:{env_ogCore_Server}:{OGCORE_SERVER}")
|
||||
logger.info(f"INSTALL_TARGET:{env_ogBoot_Dir}:{INSTALL_TARGET}")
|
||||
logger.info(f"INSTALL_OGBOOT_TARGET:{env_ogBoot_Dir}:{INSTALL_OGBOOT_TARGET}")
|
||||
logger.info(f"INSTALL_OPENGNSYS_TARGET:{env_ogCore_Dir}:{INSTALL_OPENGNSYS_TARGET}")
|
||||
logger.info(f"GIT_REPO:{env_ogBoot_GitRepo}:{GIT_REPO}")
|
||||
|
||||
if os.geteuid() != 0:
|
||||
logger.error("This program must be run with root privileges..")
|
||||
exit(1)
|
||||
|
@ -1052,11 +1065,11 @@ logger.info("Creating directories.")
|
|||
og_boot_create_dirs()
|
||||
|
||||
logger.info("Copying installation files.")
|
||||
og_boot_copy_files(INSTALL_OGBOOT_TARGET)
|
||||
og_boot_copy_files()
|
||||
|
||||
logger.info("Installing Symfony.")
|
||||
og_boot_symfony_install(INSTALL_OGBOOT_TARGET)
|
||||
og_boot_composer_install(INSTALL_OGBOOT_TARGET)
|
||||
og_boot_symfony_install()
|
||||
og_boot_composer_install()
|
||||
|
||||
|
||||
#if os.system("echo $?") != 0:
|
||||
|
|
Loading…
Reference in New Issue