refs #788 changes www.conf directory depending on php version installed, dont add fstab if is already isntalled
parent
f7daf2f5f9
commit
174d659fe2
|
|
@ -168,33 +168,42 @@ def get_missing_packages():
|
||||||
return faltantes
|
return faltantes
|
||||||
|
|
||||||
def install_packages(missing, log_packages_file="/tmp/installed_packages.log"):
|
def install_packages(missing, log_packages_file="/tmp/installed_packages.log"):
|
||||||
if not missing:
|
if not missing:
|
||||||
logger.info("All packages are already installed.")
|
logger.info("All packages are already installed.")
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info("Upgrading the system...")
|
logger.info("Upgrading the system...")
|
||||||
original_debian_frontend = os.environ.get('DEBIAN_FRONTEND')
|
original_debian_frontend = os.environ.get('DEBIAN_FRONTEND')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
|
os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
|
||||||
subprocess.run(["sudo", "apt-get", "update"], check=True)
|
subprocess.run(["sudo", "apt-get", "update"], check=True)
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["sudo", "apt-get", "install", "--allow-change-held-packages", "-y", "--no-install-recommends"] + missing,
|
["sudo", "apt-get", "install", "--allow-change-held-packages", "-y", "--no-install-recommends"] + missing,
|
||||||
check=True
|
check=True
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(log_packages_file, "a") as log:
|
with open(log_packages_file, "a") as log:
|
||||||
for package in missing:
|
for package in missing:
|
||||||
logger.info(f"{package} installed correctly.")
|
logger.info(f"{package} installed correctly.")
|
||||||
log.write(package + "\n")
|
log.write(package + "\n")
|
||||||
|
|
||||||
logger.info("All missing packages have been installed.")
|
logger.info("All missing packages have been installed.")
|
||||||
|
|
||||||
finally:
|
# Check PHP version and install corresponding php-fpm package
|
||||||
if original_debian_frontend is not None:
|
php_version = subprocess.check_output(["php", "-v"]).decode("utf-8")
|
||||||
os.environ['DEBIAN_FRONTEND'] = original_debian_frontend
|
if "PHP 8.1" in php_version:
|
||||||
else:
|
subprocess.run(["sudo", "apt-get", "install", "-y", "php8.1-fpm"], check=True)
|
||||||
del os.environ['DEBIAN_FRONTEND']
|
elif "PHP 8.3" in php_version:
|
||||||
|
subprocess.run(["sudo", "apt-get", "install", "-y", "php8.3-fpm"], check=True)
|
||||||
|
else:
|
||||||
|
logger.warning("PHP version not supported.")
|
||||||
|
|
||||||
|
finally:
|
||||||
|
if original_debian_frontend is not None:
|
||||||
|
os.environ['DEBIAN_FRONTEND'] = original_debian_frontend
|
||||||
|
else:
|
||||||
|
del os.environ['DEBIAN_FRONTEND']
|
||||||
|
|
||||||
def autoConfigure():
|
def autoConfigure():
|
||||||
global OSDISTRIB, OSVERSION
|
global OSDISTRIB, OSVERSION
|
||||||
|
|
@ -386,18 +395,25 @@ def get_ogboot_uid_gid():
|
||||||
|
|
||||||
# Añadir líneas al fstab
|
# Añadir líneas al fstab
|
||||||
def add_fstab_entries(uid, gid):
|
def add_fstab_entries(uid, gid):
|
||||||
try:
|
try:
|
||||||
fstab_entries = [
|
fstab_entries = [
|
||||||
f'/opt/ogboot/lib/oglive.iso /tmp/opt/ogboot/lib/ogLive iso9660 loop,ro,users,uid={uid},gid={gid} 0 0\n',
|
f'/opt/ogboot/lib/oglive.iso /tmp/opt/ogboot/lib/ogLive iso9660 loop,ro,users,uid={uid},gid={gid},noauto 0 0\n',
|
||||||
f'/var/lib/tftpboot/ogLive/ogclient.sqfs /tmp/ogclient_mount squashfs loop,ro,user 0 0\n'
|
f'/var/lib/tftpboot/ogLive/ogclient.sqfs /tmp/ogclient_mount squashfs loop,ro,user,noauto 0 0\n'
|
||||||
]
|
]
|
||||||
|
|
||||||
with open('/etc/fstab', 'a') as fstab:
|
with open('/etc/fstab', 'r') as fstab:
|
||||||
fstab.writelines(fstab_entries)
|
existing_entries = fstab.readlines()
|
||||||
logger.info("Entradas añadidas a /etc/fstab correctamente.")
|
|
||||||
|
# Check if the entries already exist in /etc/fstab
|
||||||
except IOError:
|
if all(entry.strip() not in existing_entries for entry in fstab_entries):
|
||||||
raise Exception("Error al escribir en /etc/fstab.")
|
with open('/etc/fstab', 'a') as fstab:
|
||||||
|
fstab.writelines(fstab_entries)
|
||||||
|
logger.info("Entradas añadidas a /etc/fstab correctamente.")
|
||||||
|
else:
|
||||||
|
logger.info("Las entradas ya existen en /etc/fstab. No se añadieron nuevamente.")
|
||||||
|
|
||||||
|
except IOError:
|
||||||
|
raise Exception("Error al escribir en /etc/fstab.")
|
||||||
|
|
||||||
# Añadir el usuario ogboot al grupo disk
|
# Añadir el usuario ogboot al grupo disk
|
||||||
def add_user_to_disk_group():
|
def add_user_to_disk_group():
|
||||||
|
|
@ -800,7 +816,7 @@ def get_php_fpm_version():
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def modify_php_fpm_config():
|
def modify_php_fpm_config():
|
||||||
php_version = "8.2" # Establecemos la versión de PHP a 8.2
|
php_version = get_php_fpm_version() # Establecemos la versión de PHP a 8.2
|
||||||
php_fpm_conf_path = f"/etc/php/{php_version}/fpm/pool.d/www.conf"
|
php_fpm_conf_path = f"/etc/php/{php_version}/fpm/pool.d/www.conf"
|
||||||
new_fpm_conf_path = f"/etc/php/{php_version}/fpm/pool.d/ogboot.conf"
|
new_fpm_conf_path = f"/etc/php/{php_version}/fpm/pool.d/ogboot.conf"
|
||||||
socket_path = f"/run/php/php{php_version}-fpm-ogboot.sock"
|
socket_path = f"/run/php/php{php_version}-fpm-ogboot.sock"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue