refs #477 Adds change of user to nginx conf
parent
c2d43334a8
commit
3b536baa7a
|
@ -863,39 +863,52 @@ 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)
|
||||
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.")
|
||||
|
||||
# Modificar el archivo de configuración de nginx para ejecutarse como ogboot
|
||||
nginx_conf_path = "/etc/nginx/nginx.conf"
|
||||
with open(nginx_conf_path, 'r') as nginx_conf_file:
|
||||
nginx_conf_content = nginx_conf_file.read()
|
||||
|
||||
nginx_conf_content = nginx_conf_content.replace("user www-data;", "user ogboot;")
|
||||
|
||||
with open(nginx_conf_path, 'w') as nginx_conf_file:
|
||||
nginx_conf_file.write(nginx_conf_content)
|
||||
|
||||
logger.info("Nginx configuration file modified to run as ogboot.")
|
||||
|
||||
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)
|
||||
|
||||
def get_php_fpm_version():
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue