refs #477 Adds exceptions to oglive daemon conf

ogboot_installer
Luis Gerardo Romero Garcia 2024-07-02 12:02:11 +02:00
parent e8d30f62e3
commit 72adbf37cf
1 changed files with 38 additions and 17 deletions

View File

@ -881,24 +881,45 @@ def setup_nginx():
exit(1) exit(1)
def install_oglive_daemon(): def install_oglive_daemon():
INSTALL_TARGET = "/opt/ogboot" try:
DAEMON_SCRIPT_SRC = os.path.join(WORKDIR, "oglive_daemon.py") DAEMON_SCRIPT_SRC = os.path.join(WORKDIR, "ogboot/bin/oglive_daemon.py")
DAEMON_SCRIPT_DEST = os.path.join(INSTALL_TARGET, "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_SRC = os.path.join(WORKDIR, "ogboot/etc/oglive_daemon.service")
SERVICE_FILE_DEST = "/etc/systemd/system/oglive_daemon.service" SERVICE_FILE_DEST = "/etc/systemd/system/oglive_daemon.service"
shutil.copyfile(DAEMON_SCRIPT_SRC, DAEMON_SCRIPT_DEST) # Crear directorio de destino si no existe
logger.info(f"Copied {DAEMON_SCRIPT_SRC} to {DAEMON_SCRIPT_DEST}") os.makedirs(os.path.dirname(DAEMON_SCRIPT_DEST), exist_ok=True)
os.chmod(DAEMON_SCRIPT_DEST, 0o755)
logger.info(f"Set executable permissions for {DAEMON_SCRIPT_DEST}") # Copiar el script del demonio al directorio de destino
shutil.copyfile(SERVICE_FILE_SRC, SERVICE_FILE_DEST) shutil.copyfile(DAEMON_SCRIPT_SRC, DAEMON_SCRIPT_DEST)
logger.info(f"Copied {SERVICE_FILE_SRC} to {SERVICE_FILE_DEST}") logger.info(f"Copied {DAEMON_SCRIPT_SRC} to {DAEMON_SCRIPT_DEST}")
subprocess.run(["systemctl", "daemon-reload"], check=True)
logger.info("Reloaded systemd daemon") # Hacer el script ejecutable
subprocess.run(["systemctl", "enable", "oglive_daemon.service"], check=True) os.chmod(DAEMON_SCRIPT_DEST, 0o755)
logger.info("Enabled oglive_daemon service") logger.info(f"Set executable permissions for {DAEMON_SCRIPT_DEST}")
subprocess.run(["systemctl", "start", "oglive_daemon.service"], check=True)
logger.info("Started oglive_daemon service") # 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 :::::::::::::::::::::::::::::::::::### ###:::::::::::::::::::::::::::::::: MAIN :::::::::::::::::::::::::::::::::::###