Refs #202 global setting is added
parent
6fc10e95df
commit
957a343fea
|
|
@ -33,6 +33,8 @@ INSTALL_OPENGNSYS_TARGET = f"{env_ogCore_Dir}"
|
||||||
INSTALL_OGBOOT_TARGET = f"{env_ogBoot_Dir}"
|
INSTALL_OGBOOT_TARGET = f"{env_ogBoot_Dir}"
|
||||||
GIT_REPO = f"{env_ogBoot_GitRepo}"
|
GIT_REPO = f"{env_ogBoot_GitRepo}"
|
||||||
|
|
||||||
|
OSDISTRIB = ""
|
||||||
|
OSVERSION = ""
|
||||||
IPXE_DIR = "/tmp/ipxe"
|
IPXE_DIR = "/tmp/ipxe"
|
||||||
WORKDIR ="/tmp/ogboot_installer"
|
WORKDIR ="/tmp/ogboot_installer"
|
||||||
TFTPSERV = "tftpd-hpa"
|
TFTPSERV = "tftpd-hpa"
|
||||||
|
|
@ -41,7 +43,7 @@ SAMBACFGDIR = "/etc/samba"
|
||||||
TFTPCFGDIR = "/var/lib/tftpboot"
|
TFTPCFGDIR = "/var/lib/tftpboot"
|
||||||
INETDCFGDIR = "/etc/xinetd.d/"
|
INETDCFGDIR = "/etc/xinetd.d/"
|
||||||
|
|
||||||
DEFAULTDEV = "enp0s3"
|
DEFAULTDEV = ""
|
||||||
PACKAGES_TO_INSTALL = ["htop"]
|
PACKAGES_TO_INSTALL = ["htop"]
|
||||||
DEVICE = []
|
DEVICE = []
|
||||||
SERVERIP = []
|
SERVERIP = []
|
||||||
|
|
@ -210,6 +212,7 @@ def install_packages(missing, log_packages_file=f"/tmp/installed_packages.log"):
|
||||||
del os.environ['DEBIAN_FRONTEND']
|
del os.environ['DEBIAN_FRONTEND']
|
||||||
|
|
||||||
def autoConfigure():
|
def autoConfigure():
|
||||||
|
global OSDISTRIB, OSVERSION
|
||||||
#distribution = platform.linux_distribution()
|
#distribution = platform.linux_distribution()
|
||||||
#distribution = distro.linux_distribution()
|
#distribution = distro.linux_distribution()
|
||||||
#OSDISTRIB = distribution[0]
|
#OSDISTRIB = distribution[0]
|
||||||
|
|
@ -234,6 +237,7 @@ def generate_config_url():
|
||||||
return f"https://dl.cloudsmith.io/public/isc/kea-2-0/config.deb.txt?distro=ubuntu&codename={codename}&version={version}&arch={arch}"
|
return f"https://dl.cloudsmith.io/public/isc/kea-2-0/config.deb.txt?distro=ubuntu&codename={codename}&version={version}&arch={arch}"
|
||||||
|
|
||||||
def downloadComposer():
|
def downloadComposer():
|
||||||
|
global WORKDIR, INSTALL_OGBOOT_TARGET
|
||||||
#logger.info("Downloading composer.phar...")
|
#logger.info("Downloading composer.phar...")
|
||||||
os.makedirs(os.path.join(WORKDIR, "ogboot", "bin"), mode=0o750, 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)
|
subprocess.run(["curl", "-sS", "-o", os.path.join(WORKDIR, "ogboot", "bin", "composer.phar"), "https://getcomposer.org/installer"], check=True)
|
||||||
|
|
@ -244,6 +248,7 @@ def downloadComposer():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def install_swagger_ui():
|
def install_swagger_ui():
|
||||||
|
global INSTALL_TARGET
|
||||||
# Define la URL del archivo de Swagger UI que quieres descargar
|
# Define la URL del archivo de Swagger UI que quieres descargar
|
||||||
swagger_ui_url = "https://github.com/swagger-api/swagger-ui/archive/refs/heads/master.zip"
|
swagger_ui_url = "https://github.com/swagger-api/swagger-ui/archive/refs/heads/master.zip"
|
||||||
# Define la ruta donde quieres descomprimir Swagger UI
|
# Define la ruta donde quieres descomprimir Swagger UI
|
||||||
|
|
@ -277,6 +282,7 @@ def og_core_create_user(OPENGNSYS_CLIENT_USER):
|
||||||
logger.info(f"User {OPENGNSYS_CLIENT_USER} created successfully.")
|
logger.info(f"User {OPENGNSYS_CLIENT_USER} created successfully.")
|
||||||
|
|
||||||
def og_boot_create_dirs():
|
def og_boot_create_dirs():
|
||||||
|
global INSTALL_OGBOOT_TARGET
|
||||||
if os.path.exists(INSTALL_OGBOOT_TARGET):
|
if os.path.exists(INSTALL_OGBOOT_TARGET):
|
||||||
if not os.path.isdir(INSTALL_OGBOOT_TARGET):
|
if not os.path.isdir(INSTALL_OGBOOT_TARGET):
|
||||||
raise NotADirectoryError(f"{INSTALL_OGBOOT_TARGET} exists and is not a directory.")
|
raise NotADirectoryError(f"{INSTALL_OGBOOT_TARGET} exists and is not a directory.")
|
||||||
|
|
@ -301,6 +307,7 @@ def og_boot_create_dirs():
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def og_boot_symfony_install(path_opengnsys_base):
|
def og_boot_symfony_install(path_opengnsys_base):
|
||||||
|
global WORKDIR
|
||||||
logger.info("Creating Symfony application skeleton...")
|
logger.info("Creating Symfony application skeleton...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -312,8 +319,8 @@ def og_boot_symfony_install(path_opengnsys_base):
|
||||||
|
|
||||||
shutil.copy(env_src, env_dest)
|
shutil.copy(env_src, env_dest)
|
||||||
shutil.copy(composer_src, composer_dest)
|
shutil.copy(composer_src, composer_dest)
|
||||||
logger.info(f"Copied {env_src} to {env_dest}")
|
logger.info(f"Copied environment source {env_src} to {env_dest}")
|
||||||
logger.info(f"Copied {composer_src} to {composer_dest}")
|
logger.info(f"Copied composer source{composer_src} to {composer_dest}")
|
||||||
|
|
||||||
# Cambiar permisos y propietario de los archivos copiados
|
# Cambiar permisos y propietario de los archivos copiados
|
||||||
os.chmod(env_dest, 0o644)
|
os.chmod(env_dest, 0o644)
|
||||||
|
|
@ -328,6 +335,7 @@ def og_boot_symfony_install(path_opengnsys_base):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def og_boot_copy_files(path_opengnsys_base):
|
def og_boot_copy_files(path_opengnsys_base):
|
||||||
|
global INSTALL_TARGET, WORKDIR
|
||||||
bin_source = os.path.join(WORKDIR, "ogboot/bin")
|
bin_source = os.path.join(WORKDIR, "ogboot/bin")
|
||||||
bin_dest = os.path.join(path_opengnsys_base, "bin")
|
bin_dest = os.path.join(path_opengnsys_base, "bin")
|
||||||
src_source = os.path.join(WORKDIR, "ogboot/src")
|
src_source = os.path.join(WORKDIR, "ogboot/src")
|
||||||
|
|
@ -465,6 +473,7 @@ def backupFile(file):
|
||||||
logger.info(f"Backup of {file} successful")
|
logger.info(f"Backup of {file} successful")
|
||||||
|
|
||||||
def isc_keaDhcpConfigure():
|
def isc_keaDhcpConfigure():
|
||||||
|
global DEVICE, NETMASK, NETIP, ROUTERIP, DNSIP, SERVERIP
|
||||||
print(f"{isc_keaDhcpConfigure.__name__}(): Configuración de muestra para el servicio DHCP de Kea.")
|
print(f"{isc_keaDhcpConfigure.__name__}(): Configuración de muestra para el servicio DHCP de Kea.")
|
||||||
errcode = 0
|
errcode = 0
|
||||||
i = 0
|
i = 0
|
||||||
|
|
@ -503,6 +512,7 @@ def isc_keaDhcpConfigure():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def testPxe():
|
def testPxe():
|
||||||
|
global TFTPCFGDIR
|
||||||
logger.info(f"Checking TFTP service... please wait.")
|
logger.info(f"Checking TFTP service... please wait.")
|
||||||
subprocess.run(["echo", "test"], stdout=open(f"{TFTPCFGDIR}/testpxe", "w"))
|
subprocess.run(["echo", "test"], stdout=open(f"{TFTPCFGDIR}/testpxe", "w"))
|
||||||
try:
|
try:
|
||||||
|
|
@ -521,6 +531,7 @@ def run_command(command):
|
||||||
print(result.stdout)
|
print(result.stdout)
|
||||||
|
|
||||||
def tftpConfigure():
|
def tftpConfigure():
|
||||||
|
global TFTPSERV, INETDSERV, TFTPCFGDIR
|
||||||
# Update the package list
|
# Update the package list
|
||||||
#print("Updating package list...")
|
#print("Updating package list...")
|
||||||
run_command("sudo apt update")
|
run_command("sudo apt update")
|
||||||
|
|
@ -613,6 +624,7 @@ TFTP_OPTIONS="--secure"
|
||||||
run_command(f"sudo ln -s {TFTPCFGDIR} {symlink_target}")
|
run_command(f"sudo ln -s {TFTPCFGDIR} {symlink_target}")
|
||||||
|
|
||||||
def servicesCompilation():
|
def servicesCompilation():
|
||||||
|
global WORKDIR
|
||||||
hayErrores = 0
|
hayErrores = 0
|
||||||
process = subprocess.run(["make"], cwd=f"{WORKDIR}/ogboot/sources/clients/ogAdmClient")
|
process = subprocess.run(["make"], cwd=f"{WORKDIR}/ogboot/sources/clients/ogAdmClient")
|
||||||
subprocess.run(["mv", f"{WORKDIR}/ogboot/sources/clients/ogAdmClient/ogAdmClient", f"{WORKDIR}/ogboot/client/shared/bin"])
|
subprocess.run(["mv", f"{WORKDIR}/ogboot/sources/clients/ogAdmClient/ogAdmClient", f"{WORKDIR}/ogboot/client/shared/bin"])
|
||||||
|
|
@ -622,6 +634,7 @@ def servicesCompilation():
|
||||||
return hayErrores
|
return hayErrores
|
||||||
|
|
||||||
def copyInterfaceAdm():
|
def copyInterfaceAdm():
|
||||||
|
global WORKDIR, INSTALL_TARGET
|
||||||
hayErrores = 0
|
hayErrores = 0
|
||||||
cp_process = subprocess.run(["cp", "-ar", f"{WORKDIR}/ogboot/sources/interface", f"{INSTALL_TARGET}/client/interfaceAdm"])
|
cp_process = subprocess.run(["cp", "-ar", f"{WORKDIR}/ogboot/sources/interface", f"{INSTALL_TARGET}/client/interfaceAdm"])
|
||||||
if cp_process.returncode != 0:
|
if cp_process.returncode != 0:
|
||||||
|
|
@ -630,6 +643,7 @@ def copyInterfaceAdm():
|
||||||
return hayErrores
|
return hayErrores
|
||||||
|
|
||||||
def copyClientFiles():
|
def copyClientFiles():
|
||||||
|
global WORKDIR, INSTALL_TARGET
|
||||||
errstatus = 0
|
errstatus = 0
|
||||||
logger.info(f"Copying OpenGnsys Client files.")
|
logger.info(f"Copying OpenGnsys Client files.")
|
||||||
source_files = glob.glob(f"{WORKDIR}/ogboot/client/shared/*")
|
source_files = glob.glob(f"{WORKDIR}/ogboot/client/shared/*")
|
||||||
|
|
@ -678,13 +692,13 @@ def get_first_network_interface_with_traffic():
|
||||||
interface = parts[0].strip()
|
interface = parts[0].strip()
|
||||||
if interface != "lo":
|
if interface != "lo":
|
||||||
traffic_data = parts[1].strip().split()
|
traffic_data = parts[1].strip().split()
|
||||||
# Recibidos y enviados
|
|
||||||
received_bytes = int(traffic_data[0])
|
received_bytes = int(traffic_data[0])
|
||||||
transmitted_bytes = int(traffic_data[8])
|
transmitted_bytes = int(traffic_data[8])
|
||||||
if received_bytes > 0 or transmitted_bytes > 0:
|
if received_bytes > 0 or transmitted_bytes > 0:
|
||||||
return interface
|
return interface
|
||||||
|
|
||||||
def getNetworkSettings():
|
def getNetworkSettings():
|
||||||
|
global DEVICE, SERVERIP, NETMASK, NETBROAD, NETIP, ROUTERIP, DEFAULTDEV
|
||||||
DHCPNET = "127.0.0.1"
|
DHCPNET = "127.0.0.1"
|
||||||
#print("getNetworkSettings(): Detecting network parameters.")
|
#print("getNetworkSettings(): Detecting network parameters.")
|
||||||
output = subprocess.check_output(["ip", "-o", "link", "show", "up"]).decode("utf-8")
|
output = subprocess.check_output(["ip", "-o", "link", "show", "up"]).decode("utf-8")
|
||||||
|
|
@ -716,7 +730,7 @@ def getNetworkSettings():
|
||||||
return (0)
|
return (0)
|
||||||
|
|
||||||
def openGnsysConfigure():
|
def openGnsysConfigure():
|
||||||
global DEFAULTDEV
|
global DEFAULTDEV, INSTALL_TARGET, SERVER_OPENGNSYS, WORKDIR
|
||||||
i = 0
|
i = 0
|
||||||
dev = ""
|
dev = ""
|
||||||
CONSOLEURL = ""
|
CONSOLEURL = ""
|
||||||
|
|
@ -734,6 +748,7 @@ def openGnsysConfigure():
|
||||||
logger.info(f"OpenGnsys config files created.")
|
logger.info(f"OpenGnsys config files created.")
|
||||||
|
|
||||||
def mount_NFS():
|
def mount_NFS():
|
||||||
|
global IPXE_DIR, INSTALL_OPENGNSYS_TARGET
|
||||||
if subprocess.call(["sudo", "mount", "-t", "nfs", "ognartefactos.evlt.uma.es:/", "/mnt"]) == 0:
|
if subprocess.call(["sudo", "mount", "-t", "nfs", "ognartefactos.evlt.uma.es:/", "/mnt"]) == 0:
|
||||||
logger.info("Properly mounted NFS system.")
|
logger.info("Properly mounted NFS system.")
|
||||||
else:
|
else:
|
||||||
|
|
@ -774,7 +789,7 @@ def mount_NFS():
|
||||||
subprocess.call(["sudo", "cp", "bin-x86_64-efi/ipxe.efi", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot"])
|
subprocess.call(["sudo", "cp", "bin-x86_64-efi/ipxe.efi", f"{INSTALL_OPENGNSYS_TARGET}/tftpboot"])
|
||||||
|
|
||||||
def generate_ipxe_script():
|
def generate_ipxe_script():
|
||||||
global DEFAULTDEV
|
global DEFAULTDEV, INSTALL_OGBOOT_TARGET, WORKDIR
|
||||||
ip_address_server = subprocess.check_output(["ifconfig", DEFAULTDEV]).decode().split("\n")[1].split()[1]
|
ip_address_server = subprocess.check_output(["ifconfig", DEFAULTDEV]).decode().split("\n")[1].split()[1]
|
||||||
template = os.path.join(WORKDIR, "ogboot/etc/dhcp_boot.ipxe.tmpl")
|
template = os.path.join(WORKDIR, "ogboot/etc/dhcp_boot.ipxe.tmpl")
|
||||||
ipxe_output = f"{INSTALL_OGBOOT_TARGET}/tftpboot/ipxe_scripts/dhcp_boot.ipxe"
|
ipxe_output = f"{INSTALL_OGBOOT_TARGET}/tftpboot/ipxe_scripts/dhcp_boot.ipxe"
|
||||||
|
|
@ -801,6 +816,7 @@ def generate_ipxe_script():
|
||||||
logger.info("ipxe files created correctly.")
|
logger.info("ipxe files created correctly.")
|
||||||
|
|
||||||
def smbConfigure():
|
def smbConfigure():
|
||||||
|
global SAMBACFGDIR, SAMBASERV, OPENGNSYS_CLIENT_PASSWD, OPENGNSYS_CLIENT_USER, PYTHON_VERSION
|
||||||
#logger.info(f"{smbConfigure.__name__}(): Configuring Samba service.")
|
#logger.info(f"{smbConfigure.__name__}(): Configuring Samba service.")
|
||||||
backupFile(f"{SAMBACFGDIR}/smb.conf")
|
backupFile(f"{SAMBACFGDIR}/smb.conf")
|
||||||
# Copiar plantilla de recursos para OpenGnsys
|
# Copiar plantilla de recursos para OpenGnsys
|
||||||
|
|
@ -842,7 +858,7 @@ def smbConfigure():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def setup_nginx():
|
def setup_nginx():
|
||||||
global DEFAULTDEV
|
global DEFAULTDEV, WORKDIR
|
||||||
try:
|
try:
|
||||||
# Obtener la IP del servidor
|
# Obtener la IP del servidor
|
||||||
ip_address_server = subprocess.check_output(["ifconfig", DEFAULTDEV]).decode().split("\n")[1].split()[1]
|
ip_address_server = subprocess.check_output(["ifconfig", DEFAULTDEV]).decode().split("\n")[1].split()[1]
|
||||||
|
|
@ -938,6 +954,7 @@ def modify_php_fpm_config():
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def install_oglive_daemon():
|
def install_oglive_daemon():
|
||||||
|
global WORKDIR, INSTALL_TARGET
|
||||||
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")
|
||||||
DAEMON_SCRIPT_DEST = os.path.join(INSTALL_TARGET, "bin", "oglive_daemon.py")
|
DAEMON_SCRIPT_DEST = os.path.join(INSTALL_TARGET, "bin", "oglive_daemon.py")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue