refs #477 Adds nginx setup function
parent
ef37018595
commit
1c899a94d7
|
@ -843,6 +843,41 @@ def get_network_interfaces():
|
|||
print(get_network_interfaces())
|
||||
#exit (0)
|
||||
|
||||
def setup_nginx():
|
||||
try:
|
||||
# Obtener la IP del servidor
|
||||
ip_address_server = subprocess.check_output(["ifconfig", "ens160"]).decode().split("\n")[1].split()[1]
|
||||
|
||||
# Leer y modificar la plantilla de configuración de nginx
|
||||
template_path = os.path.join(WORKDIR, "ogboot/etc/nginxServer.conf.tmpl")
|
||||
with open(template_path, 'r') as nginx_file:
|
||||
nginx_content = nginx_file.read()
|
||||
|
||||
nginx_content = nginx_content.replace("__SERVERIP__", ip_address_server)
|
||||
|
||||
# Ruta de destino para la configuración de nginx
|
||||
nginx_output = "/etc/nginx/sites-available/ogboot.conf"
|
||||
with open(nginx_output, 'w') as nginx_file:
|
||||
nginx_file.write(nginx_content)
|
||||
|
||||
logger.info("Nginx configuration file created successfully.")
|
||||
|
||||
# Crear el enlace simbólico en sites-enabled
|
||||
subprocess.run(["sudo", "ln", "-sf", nginx_output, "/etc/nginx/sites-enabled/ogboot.conf"])
|
||||
|
||||
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.")
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f"Subprocess error: {e}")
|
||||
exit(1)
|
||||
except OSError as e:
|
||||
logger.error(f"OS error: {e}")
|
||||
exit(1)
|
||||
|
||||
###############################################################################
|
||||
###:::::::::::::::::::::::::::::::: MAIN :::::::::::::::::::::::::::::::::::###
|
||||
###############################################################################
|
||||
|
@ -933,6 +968,10 @@ copyClientFiles()
|
|||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||
logger.error("Error creating client structure")
|
||||
|
||||
logger.info("Setup nginx")
|
||||
setup_nginx()
|
||||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||
logger.error("Error setup nginx")
|
||||
|
||||
logger.info("Configuring ogCore")
|
||||
openGnsysConfigure()
|
||||
|
|
Loading…
Reference in New Issue