Refs #202 add config environment file
parent
dd629e54f5
commit
c7fbea9231
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"ogCore_ServerIP": "172.17.8.82",
|
||||
"ogCore_Server": "opengnsys.es",
|
||||
"ogCore_Dir": "/opt/opengnsys",
|
||||
"ogBoot_Dir": "/opt/ogboot",
|
||||
"ogBoot_GitRepo": "ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git",
|
||||
"ogBootSambaUser": "ogboot",
|
||||
"ogBootSambaPass": "og"
|
||||
}
|
|
@ -1,39 +1,28 @@
|
|||
#!/usr/bin/env python3
|
||||
##################################################################################
|
||||
##### ogBoot installer script ####
|
||||
##### Developed by: Luis Gerardo Romero García <lromero@qindel.com> ####
|
||||
##### Antonio Emmanuel Guerrero Silva <aguerrero@qindel.com> ####
|
||||
##### Last: 2024-07-08 ####
|
||||
##################################################################################
|
||||
|
||||
#################################################################################
|
||||
##### ogBoot installer script ########
|
||||
##### Autor: Antonio Emmanuel Guerrero Silva <aguerrero@qindel.com> ########
|
||||
#################################################################################
|
||||
|
||||
import platform, os, sys, subprocess, datetime, shutil, pwd, glob, zipfile, urllib.request, logging, distro, re
|
||||
|
||||
# Reload variables from bashrc
|
||||
# subprocess.run(['source', '~/.bashrc'], shell=True)
|
||||
|
||||
# Leer variables de entorno
|
||||
#env_ogCore_ServerIP = os.getenv('OGCORE_SERVER_IP') #"172.17.8.82"
|
||||
#env_ogCore_Server = os.getenv('OGCORE_SERVER') #"opengnsys.es"
|
||||
#env_ogCore_Dir = os.getenv('OGCORE_DIR') #{INSTALL_OPENGNSYS_TARGET}
|
||||
#env_ogBoot_Dir = os.getenv('OGBOOT_DIR') #{INSTALL_OGBOOT_TARGET}
|
||||
#env_ogBoot_GitRepo = os.getenv('OGBOOT_GIT_REPO') #"ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git"
|
||||
|
||||
# Constantes, ambiente de desarrollo
|
||||
env_ogCore_ServerIP = "172.17.8.82"
|
||||
env_ogCore_Server = "opengnsys.es"
|
||||
env_ogCore_Dir = "/opt/opengnsys"
|
||||
env_ogBoot_Dir = "/opt/ogboot"
|
||||
env_ogBoot_GitRepo = "ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git"
|
||||
import platform, os, sys, subprocess, datetime, shutil, pwd, glob, zipfile, urllib.request, logging, distro, re, json
|
||||
|
||||
PROGRAM = os.path.splitext(os.path.basename(sys.argv[0]))[0]
|
||||
PROGRAM_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||
PROGRAM_NAME = os.path.basename(sys.argv[0])
|
||||
|
||||
OGCORE_IP = f"{env_ogCore_ServerIP}"
|
||||
OGCORE_SERVER = f"{env_ogCore_Server}"
|
||||
INSTALL_TARGET = f"{env_ogBoot_Dir}"
|
||||
INSTALL_OPENGNSYS_TARGET = f"{env_ogCore_Dir}"
|
||||
INSTALL_OGBOOT_TARGET = f"{env_ogBoot_Dir}"
|
||||
GIT_REPO = f"{env_ogBoot_GitRepo}"
|
||||
with open('config.json', 'r') as f:
|
||||
config = json.load(f)
|
||||
|
||||
OGCORE_IP = config["ogCore_ServerIP"]
|
||||
OGCORE_SERVER = config["ogCore_Server"]
|
||||
INSTALL_OPENGNSYS_TARGET = config["ogCore_Dir"]
|
||||
INSTALL_OGBOOT_TARGET = config["ogBoot_Dir"]
|
||||
INSTALL_TARGET = config["ogBoot_Dir"]
|
||||
GIT_REPO = config["ogBoot_GitRepo"]
|
||||
OPENGNSYS_CLIENT_USER = config["ogBootSambaUser"]
|
||||
OPENGNSYS_CLIENT_PASSWD = config["ogBootSambaPass"]
|
||||
|
||||
OSDISTRIB = ""
|
||||
OSVERSION = ""
|
||||
|
@ -55,8 +44,6 @@ NETBROAD = []
|
|||
ROUTERIP = []
|
||||
BRANCH = sys.argv[1] if len(sys.argv) > 1 else "main"
|
||||
INETDSERV = "xinetd"
|
||||
OPENGNSYS_CLIENT_PASSWD="og"
|
||||
OPENGNSYS_CLIENT_USER="opengnsys"
|
||||
|
||||
UBUNTU_OS_VERSION = "22"
|
||||
PYTHON_VERSION = 3
|
||||
|
@ -73,7 +60,7 @@ subprocess.run(['sudo', 'touch', log_file])
|
|||
#subprocess.run(['sudo', 'chown', 'ogboot', log_file])
|
||||
subprocess.run(['sudo', 'chmod', '777', log_file])
|
||||
|
||||
#Configurar el registro
|
||||
#Configure the log
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s %(levelname)s\t%(message)s',
|
||||
filename=f'/var/log/{PROGRAM}.log',
|
||||
|
@ -133,7 +120,7 @@ def downloadCode(url):
|
|||
logger.error("Error getting OpenGnsys code from " + url)
|
||||
return 1
|
||||
subprocess.run(["rm -f opengnsys.zip"], shell=True)
|
||||
logger.info("downloadCode(): code was downloaded")
|
||||
logger.info("downloadCog_boot_create_dirsode(): code was downloaded")
|
||||
return 0
|
||||
|
||||
###############################################################################
|
||||
|
@ -162,7 +149,7 @@ def get_missing_packages():
|
|||
case "18.04":
|
||||
PACKAGES_TO_INSTALL = ["nano", "wget", "tree"]
|
||||
case "22.04":
|
||||
PACKAGES_TO_INSTALL = ["nfs-common", "xorriso", "genisoimage", "syslinux", "liblzma-dev", "nginx", "arp-scan", "automake", "build-essential", "btrfs-progs", "composer", "curl", "ctorrent", "debootstrap", "g++-multilib", "gawk", "gettext", "graphviz", "grub-efi-amd64-signed", "jq", "libapache2-mod-php", "libdbi-dev", "libdbi1", "libev-dev", "libjansson-dev", "liblz4-tool", "libssl-dev", "moreutils", "netpipes", "php", "php-bcmath", "php-cli", "php-curl", "php-fpm", "php-gd", "php-json", "php-ldap", "php-mbstring", "php-mysql", "php8.1-common", "php-pear", "php-xml", "php-zip", "procps", "coreutils", "rsync", "samba", "schroot", "shim-signed", "squashfs-tools", "subversion", "tftpd-hpa", "udpcast", "unzip", "wakeonlan", "wget", "xinetd", "jq", "moreutils", "net-tools", "isolinux", "syslinux"]
|
||||
PACKAGES_TO_INSTALL = ["nfs-common", "xorriso", "genisoimage", "syslinux", "liblzma-dev", "nginx", "arp-scan", "automake", "build-essential", "btrfs-progs", "composer", "curl", "ctorrent", "debootstrap", "g++-multilib", "gawk", "gettext", "graphviz", "grub-efi-amd64-signed", "jq", "libapache2-mod-php", "libdbi-dev", "libdbi1", "libev-dev", "libjansson-dev", "liblz4-tool", "libssl-dev", "moreutils", "netpipes", "php", "php-bcmath", "php-cli", "php-curl", "php-fpm", "php-gd", "php-json", "php-ldap", "php-mbstring", "php-mysql", "php8.1-common", "php-pear", "php-xml", "php-zip", "procps", "coreutils", "rsync", "samba", "samba-common-bin", "schroot", "shim-signed", "squashfs-tools", "subversion", "tftpd-hpa", "udpcast", "unzip", "wakeonlan", "wget", "xinetd", "jq", "moreutils", "net-tools", "isolinux", "syslinux"]
|
||||
case _:
|
||||
PACKAGES_TO_INSTALL = ["bash", "nc", "rsync"]
|
||||
case "suse":
|
||||
|
@ -193,7 +180,7 @@ def get_missing_packages():
|
|||
|
||||
def install_packages(missing, log_packages_file=f"/tmp/installed_packages.log"):
|
||||
if not missing:
|
||||
logger.warning("All packages are already installed.")
|
||||
logger.info("All packages are already installed.")
|
||||
return
|
||||
logger.info("Upgrading the system...")
|
||||
original_debian_frontend = os.environ.get('DEBIAN_FRONTEND')
|
||||
|
@ -295,13 +282,13 @@ def og_boot_create_dirs():
|
|||
# Crear los directorios necesarios
|
||||
os.makedirs(INSTALL_OGBOOT_TARGET, mode=0o750, exist_ok=True)
|
||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "client"), mode=0o750, exist_ok=True)
|
||||
os.makedirs("/opt/ogboot/tftpboot/", mode=0o750, exist_ok=True)
|
||||
os.makedirs("/opt/ogboot/tftpboot/ipxe_scripts", mode=0o750, exist_ok=True)
|
||||
os.makedirs("/opt/ogboot/tftpboot/ipxe_scripts/templates", mode=0o750, exist_ok=True)
|
||||
# os.makedirs("/opt/ogboot/tftpboot/", mode=0o750, exist_ok=True)
|
||||
# os.makedirs("/opt/ogboot/tftpboot/ipxe_scripts", mode=0o750, exist_ok=True)
|
||||
# os.makedirs("/opt/ogboot/tftpboot/ipxe_scripts/templates", mode=0o750, exist_ok=True)
|
||||
|
||||
# Cambiar el propietario de los directorios
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", INSTALL_OGBOOT_TARGET])
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", "/opt/ogboot/tftpboot/"])
|
||||
# subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", "/opt/ogboot/tftpboot/"])
|
||||
|
||||
logger.info(f"{INSTALL_OGBOOT_TARGET} directory created successfully.")
|
||||
except OSError:
|
||||
|
@ -533,95 +520,98 @@ def run_command(command):
|
|||
print(result.stdout)
|
||||
|
||||
def tftpConfigure():
|
||||
global TFTPSERV, INETDSERV, TFTPCFGDIR
|
||||
global TFTPSERV, INETDSERV, TFTPCFGDIR
|
||||
# Update the package list
|
||||
#print("Updating package list...")
|
||||
run_command("sudo apt update")
|
||||
#print("Updating package list...")
|
||||
run_command("sudo apt update")
|
||||
|
||||
run_command("sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential")
|
||||
run_command("sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential")
|
||||
|
||||
# Install tftpd-hpa in non-interactive mode
|
||||
print("Installing tftpd-hpa...")
|
||||
run_command("sudo DEBIAN_FRONTEND=noninteractive apt install -y tftpd-hpa")
|
||||
# Install tftpd-hpa in non-interactive mode
|
||||
print("Installing tftpd-hpa...")
|
||||
run_command("sudo DEBIAN_FRONTEND=noninteractive apt install -y tftpd-hpa")
|
||||
|
||||
# Configure tftpd-hpa
|
||||
print("Configuring tftpd-hpa...")
|
||||
tftpd_config = """
|
||||
# /etc/default/tftpd-hpa
|
||||
# Configure tftpd-hpa
|
||||
print("Configuring tftpd-hpa...")
|
||||
tftpd_config = """
|
||||
# /etc/default/tftpd-hpa
|
||||
|
||||
TFTP_USERNAME="tftp"
|
||||
TFTP_DIRECTORY="/var/lib/tftpboot"
|
||||
TFTP_ADDRESS="0.0.0.0:69"
|
||||
TFTP_OPTIONS="--secure"
|
||||
"""
|
||||
with open("/tmp/tftpd-hpa", "w") as config_file:
|
||||
config_file.write(tftpd_config)
|
||||
"""
|
||||
with open("/tmp/tftpd-hpa", "w") as config_file:
|
||||
config_file.write(tftpd_config)
|
||||
|
||||
run_command("sudo mv /tmp/tftpd-hpa /etc/default/tftpd-hpa")
|
||||
run_command("sudo mv /tmp/tftpd-hpa /etc/default/tftpd-hpa")
|
||||
|
||||
# Create and set permissions for the TFTP directory
|
||||
print("Creating and setting permissions for the TFTP directory...")
|
||||
run_command("sudo mkdir -p /var/lib/tftpboot")
|
||||
run_command("sudo chown -R tftp:tftp /var/lib/tftpboot")
|
||||
run_command("sudo chmod -R 755 /var/lib/tftpboot")
|
||||
# Create and set permissions for the TFTP directory
|
||||
print("Creating and setting permissions for the TFTP directory...")
|
||||
run_command("sudo mkdir -p /var/lib/tftpboot")
|
||||
run_command("sudo chown -R tftp:tftp /var/lib/tftpboot")
|
||||
run_command("sudo chmod -R 755 /var/lib/tftpboot")
|
||||
|
||||
# Restart the tftpd-hpa service
|
||||
print("Restarting tftpd-hpa service...")
|
||||
run_command("sudo systemctl restart tftpd-hpa")
|
||||
# Restart the tftpd-hpa service
|
||||
print("Restarting tftpd-hpa service...")
|
||||
run_command("sudo systemctl restart tftpd-hpa")
|
||||
|
||||
# Check the status of the tftpd-hpa service
|
||||
print("Checking tftpd-hpa service status...")
|
||||
run_command("sudo systemctl status tftpd-hpa")
|
||||
# if TFTPSERV:
|
||||
# logger.info(f"TFTPSERV is configured: {TFTPSERV}")
|
||||
# inetd_cfg_path = f"{INETDCFGDIR}/{TFTPSERV}"
|
||||
# if os.path.isfile(inetd_cfg_path):
|
||||
# logger.error(f"The inetd configuration file exists: {inetd_cfg_path}")
|
||||
# with open(inetd_cfg_path, "r+") as file:
|
||||
# content = file.read()
|
||||
# new_content = content.replace("disable.*", "disable = no")
|
||||
# file.seek(0)
|
||||
# file.write(new_content)
|
||||
# file.truncate()
|
||||
# logger.info(f"Modified inetd configuration file: {inetd_cfg_path}")
|
||||
# else:
|
||||
# service = TFTPSERV
|
||||
# logger.info(f"Enabling and starting the service {service}.service")
|
||||
# subprocess.run(["systemctl", "enable", f"{service}.service"], check=True)
|
||||
# subprocess.run(["systemctl", "start", f"{service}.service"], check=True)
|
||||
# service = INETDSERV
|
||||
# logger.info(f"Enabling and starting the service {service}.service")
|
||||
#subprocess.run(["systemctl", "enable", f"{service}.service"], check=True)
|
||||
# subprocess.run(["systemctl", "start", f"{service}.service"], check=True)
|
||||
#Crear directorio /var/lib/tftpboot
|
||||
if not os.path.exists(TFTPCFGDIR):
|
||||
os.makedirs(TFTPCFGDIR, mode=0o750, exist_ok=True)
|
||||
logger.info(f"Directory {TFTPCFGDIR} created.")
|
||||
else:
|
||||
logger.warning(f"Directory {TFTPCFGDIR} exist.")
|
||||
#Descargar oglive
|
||||
logger.info("Downloading oglive...")
|
||||
#Temporalmente se copia desde ~/oglive
|
||||
# copiar desde el montaje /mnt/srv/artefactos/ogboot/tftpboot/
|
||||
subprocess.run(["cp", "-r", f"/tmp/tftpboot/ogLive-5.11.0-r20210413", f"{TFTPCFGDIR}/"])
|
||||
# subprocess.run(["cp", "-r", f"/tmp/ipxe/tftpboot/ipxe", f"{TFTPCFGDIR}/"])
|
||||
#Crear enlace simbólico de oglive-5.11.0-r20210413 a /var/lib/tftpboot/ogLive
|
||||
subprocess.run(["ln", "-s", f"{TFTPCFGDIR}/ogLive-5.11.0-r20210413", f"{TFTPCFGDIR}/ogLive"])
|
||||
#Crear enlace simbólico de /var/lib/tftpboot/ogLive a /var/lib/tftpboot/ogLive/ogclient
|
||||
subprocess.run(["ln", "-s", f"{TFTPCFGDIR}/ogLive", f"{TFTPCFGDIR}/ogclient"])
|
||||
|
||||
symlink_target = f"{INSTALL_OGBOOT_TARGET}/tftpboot"
|
||||
logger.info(f"Creating symbolic link from {TFTPCFGDIR} to {symlink_target}")
|
||||
if not os.path.exists(symlink_target):
|
||||
os.symlink(TFTPCFGDIR, symlink_target)
|
||||
os.chown(symlink_target, pwd.getpwnam("ogboot").pw_uid, pwd.getpwnam("ogboot").pw_gid)
|
||||
else:
|
||||
logger.warning(f"The symbolic link already exists: {symlink_target}")
|
||||
#logger.info("Creating symbolic link from /opt/ogboot/tftpboot to /var/lib/tftpboot...")
|
||||
#if os.path.islink(symlink_target):
|
||||
# run_command(f"sudo rm -rf {symlink_target}")
|
||||
#elif os.path.exists(symlink_target):
|
||||
# run_command(f"sudo ln -s {TFTPCFGDIR} {INSTALL_OGBOOT_TARGET}")
|
||||
# Check the status of the tftpd-hpa service
|
||||
print("Checking tftpd-hpa service status...")
|
||||
run_command("sudo systemctl status tftpd-hpa")
|
||||
# if TFTPSERV:
|
||||
# logger.info(f"TFTPSERV is configured: {TFTPSERV}")
|
||||
# inetd_cfg_path = f"{INETDCFGDIR}/{TFTPSERV}"
|
||||
# if os.path.isfile(inetd_cfg_path):
|
||||
# logger.error(f"The inetd configuration file exists: {inetd_cfg_path}")
|
||||
# with open(inetd_cfg_path, "r+") as file:
|
||||
# content = file.read()
|
||||
# new_content = content.replace("disable.*", "disable = no")
|
||||
# file.seek(0)
|
||||
# file.write(new_content)
|
||||
# file.truncate()
|
||||
# logger.info(f"Modified inetd configuration file: {inetd_cfg_path}")
|
||||
# else:
|
||||
# service = TFTPSERV
|
||||
# logger.info(f"Enabling and starting the service {service}.service")
|
||||
# subprocess.run(["systemctl", "enable", f"{service}.service"], check=True)
|
||||
# subprocess.run(["systemctl", "start", f"{service}.service"], check=True)
|
||||
# service = INETDSERV
|
||||
# logger.info(f"Enabling and starting the service {service}.service")
|
||||
#subprocess.run(["systemctl", "enable", f"{service}.service"], check=True)
|
||||
# subprocess.run(["systemctl", "start", f"{service}.service"], check=True)
|
||||
#Crear directorio /var/lib/tftpboot
|
||||
if not os.path.exists(TFTPCFGDIR):
|
||||
os.makedirs(TFTPCFGDIR, mode=0o750, exist_ok=True)
|
||||
logger.info(f"Directory {TFTPCFGDIR} created.")
|
||||
else:
|
||||
logger.warning(f"Directory {TFTPCFGDIR} exist.")
|
||||
#Descargar oglive
|
||||
logger.info("Downloading oglive...")
|
||||
#Temporalmente se copia desde ~/oglive
|
||||
# copiar desde el montaje /mnt/srv/artefactos/ogboot/tftpboot/
|
||||
subprocess.run(["cp", "-r", f"/tmp/tftpboot/ogLive-5.11.0-r20210413", f"{TFTPCFGDIR}/"])
|
||||
# subprocess.run(["cp", "-r", f"/tmp/ipxe/tftpboot/ipxe", f"{TFTPCFGDIR}/"])
|
||||
#Crear enlace simbólico de oglive-5.11.0-r20210413 a /var/lib/tftpboot/ogLive
|
||||
subprocess.run(["ln", "-s", f"{TFTPCFGDIR}/ogLive-5.11.0-r20210413", f"{TFTPCFGDIR}/ogLive"])
|
||||
#Crear enlace simbólico de /var/lib/tftpboot/ogLive a /var/lib/tftpboot/ogLive/ogclient
|
||||
subprocess.run(["ln", "-s", f"{TFTPCFGDIR}/ogLive", f"{TFTPCFGDIR}/ogclient"])
|
||||
symlink_target = f"{INSTALL_OGBOOT_TARGET}/tftpboot"
|
||||
logger.info(f"Creating symbolic link from {TFTPCFGDIR} to {symlink_target}")
|
||||
if not os.path.exists(symlink_target):
|
||||
os.symlink(TFTPCFGDIR, symlink_target)
|
||||
os.lchown(symlink_target, pwd.getpwnam("ogboot").pw_uid, pwd.getpwnam("ogboot").pw_gid)
|
||||
else:
|
||||
logger.warning(f"The symbolic link already exists: {symlink_target}")
|
||||
#----------------------------------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------------------------
|
||||
#logger.info("Creating symbolic link from /opt/ogboot/tftpboot to /var/lib/tftpboot...")
|
||||
#if os.path.islink(symlink_target):
|
||||
# run_command(f"sudo rm -rf {symlink_target}")
|
||||
#elif os.path.exists(symlink_target):
|
||||
# run_command(f"sudo ln -s {TFTPCFGDIR} {INSTALL_OGBOOT_TARGET}")
|
||||
#----------------------------------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------------------------
|
||||
|
||||
def servicesCompilation():
|
||||
global WORKDIR
|
||||
|
@ -746,7 +736,7 @@ def openGnsysConfigure():
|
|||
else:
|
||||
try:
|
||||
os.symlink(f"{INSTALL_TARGET}/client/etc/ogAdmClient-{DEFAULTDEV}.cfg", f"{INSTALL_TARGET}/client/etc/ogAdmClient.cfg")
|
||||
print(f"Symbolic link created: {INSTALL_TARGET}/client/etc/ogAdmClient-{DEFAULTDEV}.cfg -> {INSTALL_TARGET}/client/etc/ogAdmClient.cfg")
|
||||
logger.info (f"Symbolic link created: {INSTALL_TARGET}/client/etc/ogAdmClient-{DEFAULTDEV}.cfg -> {INSTALL_TARGET}/client/etc/ogAdmClient.cfg")
|
||||
except OSError as e:
|
||||
logger.error(f"Error creating symbolic link: {e}")
|
||||
TZ = subprocess.check_output(["timedatectl", "status"]).decode().split("\n")[2].split(":")[1].strip()
|
||||
|
@ -782,13 +772,15 @@ def mount_NFS():
|
|||
if not os.path.exists("/opt/opengnsys"):
|
||||
os.symlink("/opt/ogboot/", "/opt/opengnsys")
|
||||
logger.info("Symbolic link created successfully.")
|
||||
#logger.info(f"copy ipxe(2):::::::::::::::::::::::::::: EMBED={INSTALL_OPENGNSYS_TARGET}/tftpboot/ipxe_scripts/dhcp_boot.ipxe")
|
||||
#if subprocess.call(["sudo", "make", "-s", "bin/undionly.kpxe", f"EMBED={INSTALL_OPENGNSYS_TARGET}/tftpboot/ipxe_scripts/dhcp_boot.ipxe"]) == 0:
|
||||
# logger.info("Boot file mounted correctly.")
|
||||
#else:
|
||||
# logger.error("Failed to mount boot file.")
|
||||
# exit(1)
|
||||
logger.info("Copiando undionly.kpxe con usuario ogboot:")
|
||||
subprocess.call(["sudo", "cp", "bin/undionly.kpxe", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot"])
|
||||
subprocess.call(["sudo", "chown", "ogboot:ogboot", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot"])
|
||||
logger.info("Generando make de ipxe.efi:")
|
||||
if subprocess.call(["sudo", "make", "-s", "bin-x86_64-efi/ipxe.efi", f"EMBED={INSTALL_OPENGNSYS_TARGET}/tftpboot/ipxe_scripts/dhcp_boot.ipxe"]) == 0:
|
||||
logger.info("Properly constructed EFI file.")
|
||||
else:
|
||||
|
@ -839,7 +831,9 @@ def smbConfigure():
|
|||
with open(f"{SAMBACFGDIR}/smb.conf", "a") as file:
|
||||
file.write(f"include = {SAMBACFGDIR}/smb-ogboot.conf\n")
|
||||
service = SAMBASERV
|
||||
logger.info(f"Enabling {service} service.")
|
||||
subprocess.run(["systemctl", "enable", f"{service}.service"])
|
||||
logger.info(f"Restarting {service} service.")
|
||||
subprocess.run(["systemctl", "restart", f"{service}.service"])
|
||||
# Comprobar si se ha configurado correctamente Samba
|
||||
if subprocess.run(["systemctl", "is-active", f"{service}.service"]).returncode == 0:
|
||||
|
@ -847,22 +841,17 @@ def smbConfigure():
|
|||
else:
|
||||
logger.error(f"Failed to start {service} service.")
|
||||
return 1
|
||||
# Establecer la contraseña para el usuario opengnsys
|
||||
smbpasswd_command = f"(echo {OPENGNSYS_CLIENT_PASSWD}; echo {OPENGNSYS_CLIENT_PASSWD}) | sudo smbpasswd -s -a {OPENGNSYS_CLIENT_USER}"
|
||||
if "Python 3.7" in {PYTHON_VERSION}:
|
||||
result = subprocess.run(smbpasswd_command, shell=True, capture_output=True, text=True)
|
||||
if result.returncode == 0:
|
||||
logger.info(f"The password for the user {OPENGNSYS_CLIENT_USER} has been set correctly..")
|
||||
else:
|
||||
logger.error(f"Error setting password: {result.stderr}")
|
||||
else:
|
||||
process = subprocess.Popen(smbpasswd_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
if process.returncode == 0:
|
||||
logger.info(f"The password for the user {OPENGNSYS_CLIENT_USER} has been set correctly..")
|
||||
else:
|
||||
logger.error(f"Error setting password: {stderr}")
|
||||
logger.info(f"Added Samba configuration.")
|
||||
# Ejecutar el comando smbpasswd para agregar el usuario de Samba
|
||||
try:
|
||||
process_add = subprocess.run(
|
||||
["sudo", "smbpasswd", "-a", OPENGNSYS_CLIENT_USER],
|
||||
input=f"{OPENGNSYS_CLIENT_PASSWD}\n{OPENGNSYS_CLIENT_PASSWD}\n",
|
||||
text=True,
|
||||
check=True
|
||||
)
|
||||
logger.info(f"The password for the user {OPENGNSYS_CLIENT_USER} has been set correctly.")
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f"Error setting password: {e}")
|
||||
return 0
|
||||
|
||||
def setup_nginx():
|
||||
|
@ -1056,12 +1045,6 @@ else:
|
|||
logger.info(f"ogBoot directory not found, create a symbolic link to the directory where the code is located {WORKDIR} To {os.path.dirname(PROGRAM_DIR)}")
|
||||
os.symlink(os.path.dirname(PROGRAM_DIR), f"{WORKDIR}/ogboot")
|
||||
|
||||
#logger.info("Creating directories.")
|
||||
#createDirs(INSTALL_TARGET)
|
||||
#if os.system("echo $?") != 0:
|
||||
# logger.error("Error while creating directory paths!")
|
||||
# exit(1)
|
||||
|
||||
logger.info("Creating ogBoot project.")
|
||||
og_core_create_user("ogboot")
|
||||
|
||||
|
@ -1073,12 +1056,12 @@ og_boot_copy_files()
|
|||
|
||||
logger.info("Installing Symfony.")
|
||||
og_boot_symfony_install()
|
||||
|
||||
logger.info("Installing Composer.")
|
||||
og_boot_composer_install()
|
||||
|
||||
|
||||
#if os.system("echo $?") != 0:
|
||||
# logger.error("Error while creating skeleton directory!")
|
||||
# exit(1)
|
||||
logger.info("Configuring TFTP service.")
|
||||
tftpConfigure()
|
||||
|
||||
logger.info("Configuring IPXE services")
|
||||
generate_ipxe_script()
|
||||
|
@ -1086,9 +1069,6 @@ generate_ipxe_script()
|
|||
logger.info("Setting up NFS system")
|
||||
mount_NFS()
|
||||
|
||||
logger.info("Configuring TFTP service.")
|
||||
tftpConfigure()
|
||||
|
||||
logger.info("Compiling OpenGnsys services source code")
|
||||
servicesCompilation()
|
||||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||
|
@ -1116,7 +1096,6 @@ modify_php_fpm_config()
|
|||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||
logger.error("Error configure php fpm")
|
||||
|
||||
|
||||
logger.info("Configure ogboot daemon")
|
||||
install_oglive_daemon()
|
||||
if subprocess.run(["echo", "$?"]).returncode != 0:
|
||||
|
@ -1125,11 +1104,10 @@ if subprocess.run(["echo", "$?"]).returncode != 0:
|
|||
logger.info("Configuring ogCore")
|
||||
openGnsysConfigure()
|
||||
|
||||
|
||||
logger.info("Configuring Samba")
|
||||
smbConfigure()
|
||||
|
||||
logger.info(f"ogBoot installation finished.")
|
||||
|
||||
logging.shutdown()
|
||||
console_handler.close()
|
||||
console_handler.close()
|
Loading…
Reference in New Issue