refs #477 Adds change of user to nginx conf
parent
c2d43334a8
commit
3b536baa7a
|
|
@ -863,39 +863,52 @@ print(get_network_interfaces())
|
||||||
#exit (0)
|
#exit (0)
|
||||||
|
|
||||||
def setup_nginx():
|
def setup_nginx():
|
||||||
try:
|
try:
|
||||||
# Obtener la IP del servidor
|
# Obtener la IP del servidor
|
||||||
ip_address_server = subprocess.check_output(["ifconfig", "ens160"]).decode().split("\n")[1].split()[1]
|
ip_address_server = subprocess.check_output(["ifconfig", "ens160"]).decode().split("\n")[1].split()[1]
|
||||||
|
|
||||||
# Leer y modificar la plantilla de configuración de nginx
|
# Leer y modificar la plantilla de configuración de nginx
|
||||||
template_path = os.path.join(WORKDIR, "ogboot/etc/nginxServer.conf.tmpl")
|
template_path = os.path.join(WORKDIR, "ogboot/etc/nginxServer.conf.tmpl")
|
||||||
with open(template_path, 'r') as nginx_file:
|
with open(template_path, 'r') as nginx_file:
|
||||||
nginx_content = nginx_file.read()
|
nginx_content = nginx_file.read()
|
||||||
|
|
||||||
nginx_content = nginx_content.replace("__SERVERIP__", ip_address_server)
|
nginx_content = nginx_content.replace("__SERVERIP__", ip_address_server)
|
||||||
|
|
||||||
# Ruta de destino para la configuración de nginx
|
# Ruta de destino para la configuración de nginx
|
||||||
nginx_output = "/etc/nginx/sites-available/ogboot.conf"
|
nginx_output = "/etc/nginx/sites-available/ogboot.conf"
|
||||||
with open(nginx_output, 'w') as nginx_file:
|
with open(nginx_output, 'w') as nginx_file:
|
||||||
nginx_file.write(nginx_content)
|
nginx_file.write(nginx_content)
|
||||||
|
|
||||||
logger.info("Nginx configuration file created successfully.")
|
logger.info("Nginx configuration file created successfully.")
|
||||||
|
|
||||||
# Crear el enlace simbólico en sites-enabled
|
# Crear el enlace simbólico en sites-enabled
|
||||||
subprocess.run(["sudo", "ln", "-sf", nginx_output, "/etc/nginx/sites-enabled/ogboot.conf"])
|
subprocess.run(["sudo", "ln", "-sf", nginx_output, "/etc/nginx/sites-enabled/ogboot.conf"])
|
||||||
|
|
||||||
logger.info("Symbolic link for nginx configuration created successfully.")
|
logger.info("Symbolic link for nginx configuration created successfully.")
|
||||||
|
|
||||||
# Reiniciar el servicio de samba
|
# Reiniciar el servicio de samba
|
||||||
subprocess.run(["sudo", "systemctl", "restart", "smbd.service"])
|
subprocess.run(["sudo", "systemctl", "restart", "smbd.service"])
|
||||||
|
|
||||||
logger.info("Samba service restarted successfully.")
|
logger.info("Samba service restarted successfully.")
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
logger.error(f"Subprocess error: {e}")
|
# Modificar el archivo de configuración de nginx para ejecutarse como ogboot
|
||||||
exit(1)
|
nginx_conf_path = "/etc/nginx/nginx.conf"
|
||||||
except OSError as e:
|
with open(nginx_conf_path, 'r') as nginx_conf_file:
|
||||||
logger.error(f"OS error: {e}")
|
nginx_conf_content = nginx_conf_file.read()
|
||||||
exit(1)
|
|
||||||
|
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():
|
def get_php_fpm_version():
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue