refs #477 add function to detect php fpm version and changes php socker owner to ogboot
parent
0c19466263
commit
6f53509fad
|
@ -5,7 +5,7 @@
|
||||||
##### Autor: Antonio Emmanuel Guerrero Silva <aguerrero@qindel.com> ########
|
##### Autor: Antonio Emmanuel Guerrero Silva <aguerrero@qindel.com> ########
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
import platform, os, sys, subprocess, datetime, shutil, pwd, glob, zipfile, urllib.request, logging, distro
|
import platform, os, sys, subprocess, datetime, shutil, pwd, glob, zipfile, urllib.request, logging, distro, re
|
||||||
|
|
||||||
global PACKAGES_TO_INSTALL
|
global PACKAGES_TO_INSTALL
|
||||||
global UBUNTU_OS_VERSION
|
global UBUNTU_OS_VERSION
|
||||||
|
@ -897,6 +897,53 @@ def setup_nginx():
|
||||||
logger.error(f"OS error: {e}")
|
logger.error(f"OS error: {e}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
def get_php_fpm_version():
|
||||||
|
try:
|
||||||
|
# Obtener la versión de PHP
|
||||||
|
php_version_output = subprocess.check_output(["php", "-v"]).decode()
|
||||||
|
# Extraer la versión principal y secundaria (por ejemplo, "7.4")
|
||||||
|
match = re.search(r"PHP (\d+\.\d+)", php_version_output)
|
||||||
|
if match:
|
||||||
|
php_version = match.group(1)
|
||||||
|
return php_version
|
||||||
|
else:
|
||||||
|
raise RuntimeError("No se pudo determinar la versión de PHP.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
logger.error(f"Error al obtener la versión de PHP: {e}")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
def modify_php_fpm_config():
|
||||||
|
php_version = get_php_fpm_version()
|
||||||
|
php_fpm_conf_path = f"/etc/php/{php_version}/fpm/pool.d/www.conf"
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Leer el archivo de configuración
|
||||||
|
with open(php_fpm_conf_path, 'r') as file:
|
||||||
|
config_lines = file.readlines()
|
||||||
|
|
||||||
|
# Modificar las líneas necesarias
|
||||||
|
with open(php_fpm_conf_path, 'w') as file:
|
||||||
|
for line in config_lines:
|
||||||
|
if line.startswith('user ='):
|
||||||
|
file.write('user = www-data\n')
|
||||||
|
elif line.startswith('group ='):
|
||||||
|
file.write('group = ogboot\n')
|
||||||
|
elif line.startswith('listen.owner ='):
|
||||||
|
file.write('listen.owner = www-data\n')
|
||||||
|
elif line.startswith('listen.group ='):
|
||||||
|
file.write('listen.group = ogboot\n')
|
||||||
|
else:
|
||||||
|
file.write(line)
|
||||||
|
|
||||||
|
logger.info("PHP-FPM configuration file modified successfully.")
|
||||||
|
|
||||||
|
# Reiniciar el servicio PHP-FPM
|
||||||
|
subprocess.run(["sudo", "systemctl", "restart", f"php{php_version}-fpm"])
|
||||||
|
logger.info("PHP-FPM service restarted successfully.")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"An error occurred: {e}")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
def install_oglive_daemon():
|
def install_oglive_daemon():
|
||||||
try:
|
try:
|
||||||
DAEMON_SCRIPT_SRC = os.path.join(WORKDIR, "ogboot/bin/oglive_daemon.py")
|
DAEMON_SCRIPT_SRC = os.path.join(WORKDIR, "ogboot/bin/oglive_daemon.py")
|
||||||
|
@ -1036,6 +1083,12 @@ setup_nginx()
|
||||||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||||
logger.error("Error setup nginx")
|
logger.error("Error setup nginx")
|
||||||
|
|
||||||
|
logger.info("Configure php fpm")
|
||||||
|
modify_php_fpm_config()
|
||||||
|
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||||
|
logger.error("Error configure php fpm")
|
||||||
|
|
||||||
|
|
||||||
logger.info("Configure ogboot daemon")
|
logger.info("Configure ogboot daemon")
|
||||||
install_oglive_daemon()
|
install_oglive_daemon()
|
||||||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||||
|
|
Loading…
Reference in New Issue