refs #441 absolute paths are eliminated, converted to variables and environment parameters

ogboot_installer
qindel 2024-06-11 16:26:48 +00:00
parent 5ff3017fc9
commit c25b48aabc
1 changed files with 11 additions and 10 deletions

View File

@ -27,6 +27,7 @@ INSTALL_OPENGNSYS_TARGET = env_ogCore_Dir
INSTALL_OGBOOT_TARGET = env_ogBoot_Dir
GIT_REPO = env_ogBoot_GitRepo
IPXE_DIR = "/tmp/ipxe"
WORKDIR="/tmp/ogboot_installer"
TFTPSERV = "tftpd-hpa"
SAMBASERV = "smbd"
@ -93,7 +94,7 @@ def check_distribution():
if VERSION.startswith(UBUNTU_OS_VERSION + "."):
return
logger.info(f"The ogBoot installation has been tested with full functionality on Ubuntu. {UBUNTU_OS_VERSION}")
go_on = input("Desea continuar? [s/N]: ")
go_on = input("Would you like to continue? [s/N]: ")
if go_on.upper() != "S":
logger.error("Leaving the installation.")
exit()
@ -608,29 +609,29 @@ def mount_NFS():
exit(1)
subprocess.call(["ls", "/mnt/"])
subprocess.call(["sudo", "cp", "-r", "/mnt/srv/artefactos/ipxe/", "/tmp"])
os.chdir("/tmp/ipxe/src")
os.chdir(f"{IPXE_DIR}/src")
if subprocess.call(["sudo", "make", "-j", "4"]) == 0:
logger.info("Directory /tmp/ipxe/src correctly mounted.")
logger.info(f"Directory {IPXE_DIR}/src correctly mounted.")
else:
logger.error("ERROR\tCould not mount the directory /tmp/ipxe/src.")
logger.error(f"ERROR\tCould not mount the directory {IPXE_DIR}/src.")
exit(1)
if subprocess.call(["sudo", "make", "bin/undionly.kpxe", "EMBED=/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe"]) == 0:
if subprocess.call(["sudo", "make", "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)
subprocess.call(["sudo", "cp", "bin/undionly.kpxe", "/opt/opengnsys/tftpboot"])
if subprocess.call(["sudo", "make", "bin-x86_64-efi/ipxe.efi", "EMBED=/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe"]) == 0:
subprocess.call(["sudo", "cp", "bin/undionly.kpxe", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot"])
if subprocess.call(["sudo", "make", "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:
logger.error("Could not build EFI file.")
exit(1)
subprocess.call(["sudo", "cp", "bin-x86_64-efi/ipxe.efi", "/opt/opengnsys/tftpboot"])
subprocess.call(["sudo", "cp", "bin-x86_64-efi/ipxe.efi", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot"])
def generate_ipxe_script():
ip_address_server = subprocess.check_output(["ifconfig", "eth0"]).decode().split("\n")[1].split()[1]
template = os.path.join(WORKDIR, "ogboot/etc/dhcp_boot.ipxe.tmpl")
ipxe_output = "{INSTALL_OGBOOT_TARGET}/tftpboot/ipxe_scripts/dhcp_boot.ipxe"
ipxe_output = f"{INSTALL_OGBOOT_TARGET}/tftpboot/ipxe_scripts/dhcp_boot.ipxe"
os.makedirs(os.path.dirname(ipxe_output), exist_ok=True)
shutil.copy(template, ipxe_output)
with open(ipxe_output, "r") as ipxe_file:
@ -645,7 +646,7 @@ def generate_ipxe_script():
# with open(ipxe_output, "w") as ipxe_file:
# ipxe_file.write(ipxe_content)
template_default = os.path.join(WORKDIR, "ogboot/tftpboot/ipxe_scripts/default.ipxe")
default_output = os.path.join(INSTALL_TARGET, "tftpboot/ipxe_scripts/default.ipxe")
default_output = os.path.join(INSTALL_OGBOOT_TARGET, "tftpboot/ipxe_scripts/default.ipxe")
with open(template_default, "r") as default_tmpl_file:
default_template_content = default_tmpl_file.read()
default_ipxe_content = default_template_content.replace("__SERVERIP__", ip_address_server)