refs #442 All messages have been changed to English
parent
ff14b6b84f
commit
30c2a9eed4
|
@ -117,12 +117,12 @@ def check_python_version():
|
|||
python_version = platform.python_version()
|
||||
python_version_tuple = tuple(map(int, python_version.split('.')))
|
||||
if python_version_tuple >= (PYTHON_VERSION, 0):
|
||||
echoAndLog(f"Versión de python instalada: {python_version}")
|
||||
echoAndLog(f"Python version installed: {python_version}")
|
||||
else:
|
||||
errorAndLog(f"Versión de python es inferior a la requerida. Version instalada: {python_version}" + ".")
|
||||
errorAndLog(f"Python version is lower than required. Installed version: {python_version}" + ".")
|
||||
exit()
|
||||
except Exception as e:
|
||||
errorAndLog(f"Problema al verificar la versión de Python: {e}")
|
||||
errorAndLog(f"Problem verifying Python version: {e}")
|
||||
exit()
|
||||
|
||||
def check_distribution():
|
||||
|
@ -134,10 +134,10 @@ def check_distribution():
|
|||
break
|
||||
if VERSION.startswith(UBUNTU_OS_VERSION + "."):
|
||||
return
|
||||
echoAndLog(f"La instalación de OpenGnsys {OPENGNGYS_VERSION} se ha probado con funcionalidad completa sobre Ubuntu {UBUNTU_OS_VERSION}")
|
||||
echoAndLog(f"The ogBoot installation has been tested with full functionality on Ubuntu. {UBUNTU_OS_VERSION}")
|
||||
go_on = input("Desea continuar? [s/N]: ")
|
||||
if go_on.upper() != "S":
|
||||
errorAndLog("Abandonando la instalación.")
|
||||
errorAndLog("Leaving the installation.")
|
||||
exit()
|
||||
|
||||
def cidr2mask(cidr):
|
||||
|
@ -180,16 +180,16 @@ def get_missing_packages(packages):
|
|||
|
||||
def install_packages(missing, log_packages_file=f"/tmp/installed_packages.log"):
|
||||
if not missing:
|
||||
warningAndLog("Todos los paquetes ya están instalados.")
|
||||
warningAndLog("All packages are already installed.")
|
||||
return
|
||||
echoAndLog("Actualizando el sistema...")
|
||||
echoAndLog("Upgrading the system...")
|
||||
subprocess.run(["sudo", "apt-get", "update"], check=True)
|
||||
with open(log_packages_file, "a") as log:
|
||||
for package in missing:
|
||||
subprocess.run(["sudo", "apt-get", "install", "--force-yes", "-y", package], check=True)
|
||||
echoAndLog(f"{package} instalado correctamente.")
|
||||
echoAndLog(f"{package} installed correctly.")
|
||||
log.write(package + "\n")
|
||||
echoAndLog("Todos los paquetes faltantes han sido instalados.")
|
||||
echoAndLog("All missing packages have been installed.")
|
||||
|
||||
def autoConfigure():
|
||||
os_info = platform.uname()
|
||||
|
@ -210,7 +210,7 @@ def autoConfigure():
|
|||
OSDISTRIB = OSDISTRIB.lower()
|
||||
OSVERSION = OSVERSION.split('.')[0]
|
||||
# Configuración según la distribución GNU/Linux (usar minúsculas)
|
||||
echoAndLog(f"Distribución de OS Linux: {OSDISTRIB} {OSVERSION}")
|
||||
echoAndLog(f"Linux OS distribution: {OSDISTRIB} {OSVERSION}")
|
||||
if OSDISTRIB in ['ubuntu', 'debian', 'linuxmint']:
|
||||
DEPENDENCIES2= []
|
||||
elif OSDISTRIB in ['fedora', 'centos']:
|
||||
|
@ -270,12 +270,12 @@ def install_swagger_ui():
|
|||
shutil.rmtree(swagger_ui_path)
|
||||
# Genera el archivo swagger.json
|
||||
os.system(f"{os.path.join(INSTALL_TARGET, 'vendor', 'bin', 'openapi')} {INSTALL_TARGET}/src/OgBootBundle/Controller/ -o {destination_path}/swagger.json")
|
||||
echoAndLog(f"Swagger UI instalado en {destination_path}.")
|
||||
echoAndLog(f"Swagger UI installed on {destination_path}.")
|
||||
|
||||
def create_ogboot_project(path_opengnsys_base):
|
||||
try:
|
||||
pwd.getpwnam('ogboot')
|
||||
warningAndLog("El usuario 'ogboot' ya existe")
|
||||
warningAndLog("User 'ogboot' already exists")
|
||||
except KeyError:
|
||||
subprocess.run(["sudo", "useradd", "-m", "ogboot"])
|
||||
#PROGRAM_DIR
|
||||
|
@ -287,7 +287,7 @@ def create_ogboot_project(path_opengnsys_base):
|
|||
if not os.path.isdir(path_opengnsys_base):
|
||||
raise NotADirectoryError(f"{path_opengnsys_base} existe y no es un directorio.")
|
||||
else:
|
||||
warningAndLog(f"El directorio {path_opengnsys_base} ya existe.")
|
||||
warningAndLog(f"{path_opengnsys_base} directory already exists.")
|
||||
else:
|
||||
os.makedirs(path_opengnsys_base)
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", path_opengnsys_base])
|
||||
|
@ -304,17 +304,17 @@ def create_ogboot_project(path_opengnsys_base):
|
|||
if f'{SERVER_OPENGNSYS} opengnsys' not in hosts_content:
|
||||
with open('/etc/hosts', 'a') as hosts_file:
|
||||
hosts_file.write(f'{SERVER_OPENGNSYS} opengnsys\n')
|
||||
echoAndLog(f"Entrada {SERVER_OPENGNSYS} opengnsys] agregada a /etc/hosts")
|
||||
echoAndLog(f"Entry '{SERVER_OPENGNSYS} opengnsys' has been added to /etc/hosts")
|
||||
else:
|
||||
warningAndLog(f"La entrada '{SERVER_OPENGNSYS} opengnsys' ya existe en /etc/hosts" )
|
||||
warningAndLog(f"The entry '{SERVER_OPENGNSYS} opengnsys' already exists in /etc/hosts" )
|
||||
|
||||
echoAndLog("Creando esqueleto de la aplicación Symfony...")
|
||||
echoAndLog("Creating Symfony application skeleton...")
|
||||
downloadComposer()
|
||||
# Copiar los archivos .env y composer.json primero
|
||||
echoAndLog(f"Copiando archivos .env y composer.json... de {WORKDIR}/ogboot/.env a {path_opengnsys_base}/.env")
|
||||
echoAndLog(f"Copying files (.env and composer.json) from {WORKDIR}/ogboot/.env to {path_opengnsys_base}/.env")
|
||||
shutil.copy(f"{WORKDIR}/ogboot/.env", os.path.join(path_opengnsys_base, ".env"))
|
||||
shutil.copy(f"{WORKDIR}/ogboot/composer.json", os.path.join(path_opengnsys_base, "composer.json"))
|
||||
echoAndLog(f".env y composer.json copiados a {path_opengnsys_base}")
|
||||
echoAndLog(f".env and composer.json files copied to {path_opengnsys_base}")
|
||||
bin_source = os.path.join(WORKDIR, "ogboot/bin")
|
||||
bin_dest = os.path.join(path_opengnsys_base, "bin")
|
||||
src_source = os.path.join(WORKDIR, "ogboot/src")
|
||||
|
@ -343,6 +343,7 @@ def create_ogboot_project(path_opengnsys_base):
|
|||
shutil.copytree(lib_source, lib_dest)
|
||||
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "etc"))
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "client"))
|
||||
|
||||
subprocess.run(["sudo", "chmod", "-R", "755", path_opengnsys_base])
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", path_opengnsys_base])
|
||||
|
@ -352,7 +353,7 @@ def create_ogboot_project(path_opengnsys_base):
|
|||
os.chdir(os.path.join(path_opengnsys_base, 'bin'))
|
||||
result = subprocess.run(["sudo", "-u", "ogboot", "php", os.path.join(path_opengnsys_base, "bin", "composer.phar"), "install", "--no-interaction", "--working-dir", path_opengnsys_base])
|
||||
if result.returncode != 0:
|
||||
errorAndLog("Error al crear el proyecto Symfony usando Composer")
|
||||
errorAndLog("Error creating Symfony project using Composer")
|
||||
return
|
||||
os.chdir(path_opengnsys_base)
|
||||
result = subprocess.run(["sudo", "-u", "ogboot", "php", os.path.join(path_opengnsys_base, "bin", "composer.phar"), "install", "--no-interaction", "--working-dir", path_opengnsys_base])
|
||||
|
@ -363,14 +364,14 @@ def create_ogboot_project(path_opengnsys_base):
|
|||
|
||||
install_swagger_ui() # Instalar Swagger UI
|
||||
|
||||
echoAndLog("Esqueleto de la aplicación creado y archivo composer.lock eliminado.")
|
||||
echoAndLog("Application skeleton created and composer.lock file removed.")
|
||||
|
||||
def createDirs(INSTALL_TARGET):
|
||||
if not os.path.exists(INSTALL_TARGET):
|
||||
try:
|
||||
os.makedirs(INSTALL_TARGET)
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "client"))
|
||||
echoAndLog(f"Directorio {INSTALL_TARGET} creado correctamente.")
|
||||
echoAndLog(f"{INSTALL_TARGET} directory created successfully.")
|
||||
except OSError:
|
||||
errorAndLog("Error while creating directory paths!")
|
||||
exit(1)
|
||||
|
@ -501,46 +502,47 @@ def testPxe():
|
|||
|
||||
def tftpConfigure():
|
||||
if TFTPSERV:
|
||||
echoAndLog(f"TFTPSERV está configurado: {TFTPSERV}")
|
||||
echoAndLog(f"TFTPSERV is configured: {TFTPSERV}")
|
||||
inetd_cfg_path = f"{INETDCFGDIR}/{TFTPSERV}"
|
||||
if os.path.isfile(inetd_cfg_path):
|
||||
errorAndLog(f"El archivo de configuración de inetd existe: {inetd_cfg_path}")
|
||||
errorAndLog(f"The inetd configuration file exists: {inetd_cfg_path}")
|
||||
with open(inetd_cfg_path, "r+") as file:
|
||||
content = file.read()
|
||||
new_content = content.replace("disable.*", "disable = no")
|
||||
file.seek(0)
|
||||
file.write(new_content)
|
||||
file.truncate()
|
||||
echoAndLog(f"Archivo de configuración de inetd modificado: {inetd_cfg_path}")
|
||||
echoAndLog(f"Modified inetd configuration file: {inetd_cfg_path}")
|
||||
else:
|
||||
service = TFTPSERV
|
||||
echoAndLog(f"Habilitando y arrancando el servicio {service}.service")
|
||||
echoAndLog(f"Enabling and starting the service {service}.service")
|
||||
subprocess.run(["systemctl", "enable", f"{service}.service"], check=True)
|
||||
subprocess.run(["systemctl", "start", f"{service}.service"], check=True)
|
||||
service = INETDSERV
|
||||
echoAndLog(f"Habilitando y arrancando el servicio {service}.service")
|
||||
echoAndLog(f"Enabling and starting the service {service}.service")
|
||||
subprocess.run(["systemctl", "enable", f"{service}.service"], check=True)
|
||||
subprocess.run(["systemctl", "start", f"{service}.service"], check=True)
|
||||
#Crear directorio /var/lib/tftpboot
|
||||
if not os.path.exists(TFTPCFGDIR):
|
||||
os.makedirs(TFTPCFGDIR)
|
||||
echoAndLog(f"Directorio {TFTPCFGDIR} creado.")
|
||||
echoAndLog(f"Directory {TFTPCFGDIR} created.")
|
||||
#Descargar oglive
|
||||
echoAndLog("Downloading oglive...")
|
||||
#Temporalmente se copia desde ~/oglive
|
||||
subprocess.run(["cp", "-r", f"{PROGRAM_DIR}/../../oglive/ogLive-5.11.0-r20210413", f"/var/lib/tftpboot/"])
|
||||
subprocess.run(["cp", "-r", f"{PROGRAM_DIR}/../../tftpboot/ipxe_scripts", f"/var/lib/tftpboot/"])
|
||||
#Crear enlace simbólico de oglive-5.11.0-r20210413 a /var/lib/tftpboot/ogLive
|
||||
subprocess.run(["ln", "-s", f"/var/lib/tftpboot/ogLive-5.11.0-r20210413", "/var/lib/tftpboot/ogLive"])
|
||||
#Crear enlace simbólico de /var/lib/tftpboot/ogLive a /var/lib/tftpboot/ogLive/ogclient
|
||||
subprocess.run(["ln", "-s", "/var/lib/tftpboot/ogLive", "/var/lib/tftpboot/ogclient"])
|
||||
|
||||
symlink_target = f"{INSTALL_TARGET}/tftpboot"
|
||||
echoAndLog(f"Creando enlace simbólico de /var/lib/tftpboot a {symlink_target}")
|
||||
echoAndLog(f"Creating symbolic link from /var/lib/tftpboot to {symlink_target}")
|
||||
if not os.path.exists(symlink_target):
|
||||
os.symlink("/var/lib/tftpboot", symlink_target)
|
||||
os.chown(symlink_target, pwd.getpwnam("ogboot").pw_uid, pwd.getpwnam("ogboot").pw_gid)
|
||||
else:
|
||||
warningAndLog(f"El enlace simbólico ya existe: {symlink_target}")
|
||||
warningAndLog(f"The symbolic link already exists: {symlink_target}")
|
||||
|
||||
def servicesCompilation():
|
||||
hayErrores = 0
|
||||
|
@ -649,28 +651,28 @@ def openGnsysConfigure():
|
|||
|
||||
def mount_NFS():
|
||||
if subprocess.call(["sudo", "mount", "-t", "nfs", "ognartefactos.evlt.uma.es:/", "/mnt"]) == 0:
|
||||
echoAndLog("Sistema NFS montado correctamente.")
|
||||
echoAndLog("Properly mounted NFS system.")
|
||||
else:
|
||||
errorAndLog("No se pudo montar el sistema NFS.")
|
||||
errorAndLog("Could not mount the NFS system.")
|
||||
exit(1)
|
||||
subprocess.call(["ls", "/mnt/"])
|
||||
subprocess.call(["sudo", "cp", "-r", "/mnt/srv/artefactos/ipxe/", "/tmp"])
|
||||
os.chdir("/tmp/ipxe/src")
|
||||
if subprocess.call(["sudo", "make", "-j", "4"]) == 0:
|
||||
echoAndLog("Directorio /tmp/ipxe/src montado correctamente.")
|
||||
echoAndLog("Directory /tmp/ipxe/src correctly mounted.")
|
||||
else:
|
||||
errorAndLog("ERROR\tNo se pudo montar el directorio /tmp/ipxe/src.")
|
||||
errorAndLog("ERROR\tCould not mount the directory /tmp/ipxe/src.")
|
||||
exit(1)
|
||||
if subprocess.call(["sudo", "make", "bin/undionly.kpxe", "EMBED=/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe"]) == 0:
|
||||
echoAndLog("Fichero de arranque montado correctamente.")
|
||||
echoAndLog("Boot file mounted correctly.")
|
||||
else:
|
||||
errorAndLog("No se pudo montar el fichero de arranque.")
|
||||
errorAndLog("Failed to mount boot file.")
|
||||
exit(1)
|
||||
subprocess.call(["sudo", "cp", "bin/undionly.kpxe", "/opt/opengnsys/tftpboot"])
|
||||
if subprocess.call(["sudo", "make", "bin-x86_64-efi/ipxe.efi", "EMBED=/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe"]) == 0:
|
||||
echoAndLog("Fichero EFI construido correctamente.")
|
||||
echoAndLog("Properly constructed EFI file.")
|
||||
else:
|
||||
errorAndLog("No se pudo construir el fichero EFI.")
|
||||
errorAndLog("Could not build EFI file.")
|
||||
exit(1)
|
||||
subprocess.call(["sudo", "cp", "bin-x86_64-efi/ipxe.efi", "/opt/opengnsys/tftpboot"])
|
||||
|
||||
|
@ -698,7 +700,7 @@ def generate_ipxe_script():
|
|||
default_ipxe_content = default_template_content.replace("__SERVERIP__", ip_address_server)
|
||||
with open(default_output, "w") as default_ipxe_file:
|
||||
default_ipxe_file.write(default_ipxe_content)
|
||||
echoAndLog("Archivos ipxe creados correctamente.")
|
||||
echoAndLog("ipxe files created correctly.")
|
||||
|
||||
def smbConfigure():
|
||||
#echoAndLog(f"{smbConfigure.__name__}(): Configuring Samba service.")
|
||||
|
@ -728,16 +730,16 @@ def smbConfigure():
|
|||
if "Python 3.7" in {PYTHON_VERSION}:
|
||||
result = subprocess.run(smbpasswd_command, shell=True, capture_output=True, text=True)
|
||||
if result.returncode == 0:
|
||||
echoAndLog(f"La contraseña para el usuario {OPENGNSYS_CLIENT_USER} se ha establecido correctamente.")
|
||||
echoAndLog(f"The password for the user {OPENGNSYS_CLIENT_USER} has been set correctly..")
|
||||
else:
|
||||
errorAndLog(f"Error al establecer la contraseña: {result.stderr}")
|
||||
errorAndLog(f"Error setting password: {result.stderr}")
|
||||
else:
|
||||
process = subprocess.Popen(smbpasswd_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
if process.returncode == 0:
|
||||
echoAndLog(f"La contraseña para el usuario {OPENGNSYS_CLIENT_USER} se ha establecido correctamente.")
|
||||
echoAndLog(f"The password for the user {OPENGNSYS_CLIENT_USER} has been set correctly..")
|
||||
else:
|
||||
errorAndLog(f"Error al establecer la contraseña: {stderr}")
|
||||
errorAndLog(f"Error setting password: {stderr}")
|
||||
echoAndLog(f"Added Samba configuration.")
|
||||
return 0
|
||||
|
||||
|
@ -747,29 +749,29 @@ def smbConfigure():
|
|||
|
||||
echoAndLog(f"Starting installation of ogBoot.")
|
||||
if os.geteuid() != 0:
|
||||
errorAndLog("Este programa debe ejecutarse con privilegios de root.")
|
||||
errorAndLog("This program must be run with root privileges..")
|
||||
exit(1)
|
||||
if os.path.exists(os.path.join(INSTALL_OGBOOT_TARGET + "/doc/")):
|
||||
warningAndLog(f"ogBoot ya esta instalado. Ejecute {INSTALL_OGBOOT_TARGET}/lib/ogboot_devel_update.py\" con privilegios de root para actualizar.")
|
||||
warningAndLog(f"ogBoot is already installed. Run {INSTALL_OGBOOT_TARGET}/lib/ogboot_devel_update.py” with root privileges to update..")
|
||||
exit(2)
|
||||
|
||||
echoAndLog("Verificando la distribución y la versión de Python.")
|
||||
echoAndLog("Verifying Python distribution and version.")
|
||||
check_distribution()
|
||||
check_python_version()
|
||||
|
||||
echoAndLog("Verificando el sistema operativo.")
|
||||
echoAndLog("Checking the operating system.")
|
||||
autoConfigure()
|
||||
|
||||
echoAndLog("Instalando paquetes necesarios.")
|
||||
echoAndLog("Installing necessary packages.")
|
||||
Missing = get_missing_packages (required_packages_18)
|
||||
install_packages(Missing)
|
||||
|
||||
echoAndLog("Obteniendo la configuración de red por defecto.")
|
||||
echoAndLog("Obtaining the default network configuration.")
|
||||
if getNetworkSettings() != 0:
|
||||
errorAndLog("Error reading default network settings.")
|
||||
exit(1)
|
||||
|
||||
echoAndLog("Configurando repositorios de paquetes.")
|
||||
echoAndLog("Configuring package repositories.")
|
||||
if REMOTE == 1:
|
||||
downloadCode(GIT_REPO)
|
||||
if os.system("echo $?") != 0:
|
||||
|
@ -777,54 +779,54 @@ if REMOTE == 1:
|
|||
exit(1)
|
||||
else:
|
||||
if not os.path.exists(f"{WORKDIR}/ogboot"):
|
||||
echoAndLog(f"No existe {WORKDIR}/ogboot")
|
||||
echoAndLog(f"Does not exist {WORKDIR}/ogboot")
|
||||
if not os.path.exists(WORKDIR):
|
||||
os.makedirs(WORKDIR)
|
||||
errorAndLog(f"ogBoot directory not found, create a symbolic link to the directory where the code is located {WORKDIR} To {os.path.dirname(PROGRAM_DIR)}")
|
||||
os.symlink(os.path.dirname(PROGRAM_DIR), f"{WORKDIR}/ogboot")
|
||||
|
||||
echoAndLog("Creando directorios.")
|
||||
echoAndLog("Creating directories.")
|
||||
createDirs(INSTALL_TARGET)
|
||||
if os.system("echo $?") != 0:
|
||||
errorAndLog("Error while creating directory paths!")
|
||||
exit(1)
|
||||
|
||||
echoAndLog("Creando proyecto ogBoot.")
|
||||
echoAndLog("Creating ogBoot project.")
|
||||
create_ogboot_project(INSTALL_TARGET)
|
||||
if os.system("echo $?") != 0:
|
||||
errorAndLog("Error while creating skeleton directory!")
|
||||
exit(1)
|
||||
|
||||
echoAndLog("Configurando servicio TFTP.")
|
||||
echoAndLog("Configuring TFTP service.")
|
||||
tftpConfigure()
|
||||
|
||||
echoAndLog("Compilar código fuente de los servicios de OpenGnsys")
|
||||
echoAndLog("Compiling OpenGnsys services source code")
|
||||
servicesCompilation()
|
||||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||
errorAndLog("Error while compiling OpenGnsys services")
|
||||
exit(1)
|
||||
|
||||
echoAndLog("Copiar carpeta Interface entre administración y motor de clonación")
|
||||
echoAndLog("Copy folder Interface between administration and cloning engine")
|
||||
copyInterfaceAdm()
|
||||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||
errorAndLog("Error while copying Administration Interface")
|
||||
exit(1)
|
||||
|
||||
echoAndLog("Crear la estructura de los accesos al servidor desde el cliente (shared)")
|
||||
echoAndLog("Create the structure of the accesses to the server from the client (shared)")
|
||||
copyClientFiles()
|
||||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||
errorAndLog("Error creating client structure")
|
||||
|
||||
echoAndLog("Configurando servicios IPXE")
|
||||
echoAndLog("Configuring IPXE services")
|
||||
generate_ipxe_script()
|
||||
|
||||
echoAndLog("Configurando openGnsys")
|
||||
echoAndLog("Configuring ogCore")
|
||||
openGnsysConfigure()
|
||||
|
||||
echoAndLog("Montando sistema NFS")
|
||||
echoAndLog("Setting up NFS system")
|
||||
mount_NFS()
|
||||
|
||||
echoAndLog("Configurando Samba")
|
||||
echoAndLog("Configuring Samba")
|
||||
smbConfigure()
|
||||
|
||||
echoAndLog(f"ogBoot installation finished.")
|
||||
|
|
Loading…
Reference in New Issue