refs #404 removes ogboot_daemon and adds permisions ogboot to /tmp/opt/ogboot to install oglives

ogboot_debian_installer
Luis Gerardo Romero Garcia 2024-09-02 12:18:58 +02:00
parent e7a88d5f01
commit 7412653ebb
1 changed files with 12 additions and 51 deletions

View File

@ -1,4 +1,3 @@
import os
#!/usr/bin/env python3
##################################################################################
##### ogBoot installer script ####
@ -318,6 +317,12 @@ def og_boot_copy_files():
lib_source = os.path.join(WORKDIR, "ogboot/lib")
lib_dest = os.path.join(INSTALL_OGBOOT_TARGET, "lib")
# Crear el directorio /tmp/opt
os.makedirs("/tmp/opt")
# Cambiar el propietario del directorio
subprocess.run(["sudo", "chown", "ogboot:ogboot", "/tmp/opt"])
if os.path.exists(bin_dest):
shutil.rmtree(bin_dest)
shutil.copytree(bin_source, bin_dest)
@ -489,7 +494,7 @@ TFTP_OPTIONS="--secure"
iso_url = "https://ognproject.evlt.uma.es/trac/downloads/ogLive-focal-5.13.0-27-beta-amd64-r20210706.5b4bf5f.iso"
try:
result = subprocess.run(
["sudo", "/opt/ogboot/bin/oglivecli", "download", iso_url],
["sudo", "-u", "ogboot", "/opt/ogboot/bin/oglivecli", "download", iso_url],
check=True,
capture_output=True,
text=True
@ -694,6 +699,8 @@ def mount_NFS():
subprocess.call(["sudo", "chown", "-R", "tftp:ogboot", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot/"])
subprocess.run(["sudo", "chmod", "-R", "775", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot/"])
os.makedirs(f"{INSTALL_OPENGNSYS_TARGET}/tftpboot/ipxe_scripts/templates", exist_ok=True)
subprocess.call(["sudo", "chown", "-R", "tftp:ogboot", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot/ipxe_scripts/templates"])
subprocess.call(["sudo", "chmod", "-R", "775", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot/ipxe_scripts/templates"])
subprocess.call(["sudo", "cp", f"{WORKDIR}/ogboot/tftpboot/ipxe_scripts/templates/pxe_default", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot/ipxe_scripts/templates"])
@ -833,9 +840,6 @@ def setup_nginx():
logger.info("Symbolic link for nginx configuration created successfully.")
# Reiniciar el servicio de samba
subprocess.run(["sudo", "systemctl", "restart", "smbd.service"])
logger.info("Samba service restarted successfully.")
# Modificar el archivo de configuración de nginx para ejecutarse como ogboot
@ -849,6 +853,9 @@ def setup_nginx():
nginx_conf_file.write(nginx_conf_content)
logger.info("Nginx configuration file modified to run as ogboot.")
# Reiniciar el servicio de samba
subprocess.run(["sudo", "systemctl", "restart", "nginx.service"])
except subprocess.CalledProcessError as e:
logger.error(f"Subprocess error: {e}")
@ -904,47 +911,6 @@ def modify_php_fpm_config():
logger.error(f"An error occurred: {e}")
exit(1)
def install_oglive_daemon():
global WORKDIR, INSTALL_TARGET
try:
DAEMON_SCRIPT_SRC = os.path.join(WORKDIR, "ogboot/bin/oglive_daemon.py")
DAEMON_SCRIPT_DEST = os.path.join(INSTALL_TARGET, "bin", "oglive_daemon.py")
SERVICE_FILE_SRC = os.path.join(WORKDIR, "ogboot/etc/oglive_daemon.service")
SERVICE_FILE_DEST = "/etc/systemd/system/oglive_daemon.service"
# Crear directorio de destino si no existe
os.makedirs(os.path.dirname(DAEMON_SCRIPT_DEST), exist_ok=True)
# Copiar el script del demonio al directorio de destino
shutil.copyfile(DAEMON_SCRIPT_SRC, DAEMON_SCRIPT_DEST)
logger.info(f"Copied {DAEMON_SCRIPT_SRC} to {DAEMON_SCRIPT_DEST}")
# Hacer el script ejecutable
os.chmod(DAEMON_SCRIPT_DEST, 0o775)
logger.info(f"Set executable permissions for {DAEMON_SCRIPT_DEST}")
# Copiar el archivo de servicio de systemd
shutil.copyfile(SERVICE_FILE_SRC, SERVICE_FILE_DEST)
logger.info(f"Copied {SERVICE_FILE_SRC} to {SERVICE_FILE_DEST}")
# Recargar systemd para reconocer el nuevo servicio
subprocess.run(["systemctl", "daemon-reload"], check=True)
logger.info("Reloaded systemd daemon")
# Habilitar el servicio para que arranque al inicio
subprocess.run(["systemctl", "enable", "oglive_daemon.service"], check=True)
logger.info("Enabled oglive_daemon service")
# Arrancar el servicio
subprocess.run(["systemctl", "start", "oglive_daemon.service"], check=True)
logger.info("Started oglive_daemon service")
except (shutil.Error, OSError) as e:
logger.error(f"File operation error: {e}")
except subprocess.CalledProcessError as e:
logger.error(f"Subprocess error: {e}")
except Exception as e:
logger.error(f"An unexpected error occurred: {e}")
###############################################################################
###:::::::::::::::::::::::::::::::: MAIN :::::::::::::::::::::::::::::::::::###
@ -1053,11 +1019,6 @@ modify_php_fpm_config()
if subprocess.run(["echo", "$?"]).returncode != 0:
logger.error("Error configure php fpm")
logger.info("Configure ogboot daemon")
install_oglive_daemon()
if subprocess.run(["echo", "$?"]).returncode != 0:
logger.error("Error configure ogboot daemon")
logger.info("Configuring ogCore")
openGnsysConfigure()