refs #441 settings are added to adjust the permissions
parent
c25b48aabc
commit
0c6691ad4a
|
@ -206,7 +206,7 @@ def generate_config_url():
|
|||
|
||||
def downloadComposer():
|
||||
#logger.info("Downloading composer.phar...")
|
||||
os.makedirs(os.path.join(WORKDIR, "ogboot", "bin"), exist_ok=True)
|
||||
os.makedirs(os.path.join(WORKDIR, "ogboot", "bin"), mode=0o750, exist_ok=True)
|
||||
subprocess.run(["curl", "-sS", "-o", os.path.join(WORKDIR, "ogboot", "bin", "composer.phar"), "https://getcomposer.org/installer"], check=True)
|
||||
if not os.path.isfile(os.path.join(WORKDIR, "ogboot", "bin", "composer.phar")):
|
||||
logger.error("Failed to download composer.phar")
|
||||
|
@ -247,15 +247,21 @@ def og_core_create_user(OPENGNSYS_CLIENT_USER):
|
|||
subprocess.run(["sudo", "useradd", "-m", OPENGNSYS_CLIENT_USER])
|
||||
logger.info(f"User {OPENGNSYS_CLIENT_USER} created successfully.")
|
||||
|
||||
def og_boot_create_dirs(path_opengnsys_base):
|
||||
if os.path.exists(path_opengnsys_base):
|
||||
if not os.path.isdir(path_opengnsys_base):
|
||||
raise NotADirectoryError(f"{path_opengnsys_base} existe y no es un directorio.")
|
||||
def og_boot_create_dirs():
|
||||
if os.path.exists(INSTALL_OGBOOT_TARGET):
|
||||
if not os.path.isdir(INSTALL_OGBOOT_TARGET):
|
||||
raise NotADirectoryError(f"{INSTALL_OGBOOT_TARGET} exists and is not a directory.")
|
||||
else:
|
||||
logger.warning(f"{path_opengnsys_base} directory already exists.")
|
||||
logger.warning(f"{INSTALL_OGBOOT_TARGET} directory already exists.")
|
||||
else:
|
||||
os.makedirs(path_opengnsys_base)
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", path_opengnsys_base])
|
||||
try:
|
||||
os.makedirs(INSTALL_OGBOOT_TARGET, mode=0o750, exist_ok=True)
|
||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "client"), mode=0o750, exist_ok=True)
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", INSTALL_OGBOOT_TARGET])
|
||||
logger.info(f"{INSTALL_OGBOOT_TARGET} directory created successfully.")
|
||||
except OSError:
|
||||
logger.error("Error while creating directory paths!")
|
||||
exit(1)
|
||||
|
||||
def og_boot_symfony_install(path_opengnsys_base):
|
||||
logger.info("Creating Symfony application skeleton...")
|
||||
|
@ -294,8 +300,8 @@ def og_boot_copy_files(path_opengnsys_base):
|
|||
shutil.rmtree(lib_dest)
|
||||
shutil.copytree(lib_source, lib_dest)
|
||||
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "etc"))
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "client"))
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "etc"), mode=0o750, exist_ok=True)
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "client"), mode=0o750, exist_ok=True)
|
||||
|
||||
subprocess.run(["sudo", "chmod", "-R", "755", path_opengnsys_base])
|
||||
subprocess.run(["sudo", "chown", "-R", "ogboot:ogboot", path_opengnsys_base])
|
||||
|
@ -318,17 +324,17 @@ def og_boot_composer_install(path_opengnsys_base):
|
|||
|
||||
logger.info("Application skeleton created and composer.lock file removed.")
|
||||
|
||||
def createDirs(INSTALL_TARGET):
|
||||
if not os.path.exists(INSTALL_TARGET):
|
||||
try:
|
||||
os.makedirs(INSTALL_TARGET)
|
||||
os.makedirs(os.path.join(INSTALL_TARGET, "client"))
|
||||
logger.info(f"{INSTALL_TARGET} directory created successfully.")
|
||||
except OSError:
|
||||
logger.error("Error while creating directory paths!")
|
||||
exit(1)
|
||||
else:
|
||||
logger.info(f"Directory {INSTALL_TARGET} already exists.")
|
||||
#def createDirs(INSTALL_TARGET):
|
||||
# if not os.path.exists(INSTALL_TARGET):
|
||||
# try:
|
||||
# os.makedirs(INSTALL_TARGET)
|
||||
# os.makedirs(os.path.join(INSTALL_TARGET, "client"))
|
||||
# logger.info(f"{INSTALL_TARGET} directory created successfully.")
|
||||
# except OSError:
|
||||
# logger.error("Error while creating directory paths!")
|
||||
# exit(1)
|
||||
# else:
|
||||
# logger.info(f"Directory {INSTALL_TARGET} already exists.")
|
||||
|
||||
###############################################################################
|
||||
###:::::::::::::::::::::::::::: CONFIGURE ::::::::::::::::::::::::::::::::::###
|
||||
|
@ -476,7 +482,7 @@ def tftpConfigure():
|
|||
subprocess.run(["systemctl", "start", f"{service}.service"], check=True)
|
||||
#Crear directorio /var/lib/tftpboot
|
||||
if not os.path.exists(TFTPCFGDIR):
|
||||
os.makedirs(TFTPCFGDIR)
|
||||
os.makedirs(TFTPCFGDIR, mode=0o750, exist_ok=True)
|
||||
logger.info(f"Directory {TFTPCFGDIR} created.")
|
||||
#Descargar oglive
|
||||
logger.info("Downloading oglive...")
|
||||
|
@ -524,7 +530,7 @@ def copyClientFiles():
|
|||
logger.error(f"Error while copying client structure: {file}")
|
||||
errstatus = 1
|
||||
logger.info(f"Copying OpenGnsys Cloning Engine files.")
|
||||
os.makedirs(f"{INSTALL_TARGET}/client/lib/engine/bin", exist_ok=True)
|
||||
os.makedirs(f"{INSTALL_TARGET}/client/lib/engine/bin", mode=0o750, exist_ok=True)
|
||||
engine_files = glob.glob(f"{WORKDIR}/ogboot/client/engine/*.lib*")
|
||||
# Copiar cada archivo individualmente
|
||||
for file in engine_files:
|
||||
|
@ -632,7 +638,7 @@ 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 = f"{INSTALL_OGBOOT_TARGET}/tftpboot/ipxe_scripts/dhcp_boot.ipxe"
|
||||
os.makedirs(os.path.dirname(ipxe_output), exist_ok=True)
|
||||
os.makedirs(os.path.dirname(ipxe_output), mode=0o750, exist_ok=True)
|
||||
shutil.copy(template, ipxe_output)
|
||||
with open(ipxe_output, "r") as ipxe_file:
|
||||
ipxe_content = ipxe_file.read()
|
||||
|
@ -733,23 +739,26 @@ else:
|
|||
if not os.path.exists(f"{WORKDIR}/ogboot"):
|
||||
logger.info(f"Does not exist {WORKDIR}/ogboot")
|
||||
if not os.path.exists(WORKDIR):
|
||||
os.makedirs(WORKDIR)
|
||||
os.makedirs(WORKDIR, mode=0o750, exist_ok=True)
|
||||
logger.error(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 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")
|
||||
|
||||
og_boot_create_dirs(INSTALL_OGBOOT_TARGET)
|
||||
logger.info("Creating directories.")
|
||||
og_boot_create_dirs()
|
||||
|
||||
logger.info("Installing Symfony.")
|
||||
og_boot_symfony_install(INSTALL_OGBOOT_TARGET)
|
||||
|
||||
logger.info("Copying installation files.")
|
||||
og_boot_copy_files(INSTALL_OGBOOT_TARGET)
|
||||
if os.system("echo $?") != 0:
|
||||
logger.error("Error while creating skeleton directory!")
|
||||
|
|
Loading…
Reference in New Issue