From fedac2cbb76186f0fba35d219e491c53ecb898fc Mon Sep 17 00:00:00 2001 From: Antonio Guerrero Date: Thu, 9 May 2024 21:44:25 +0000 Subject: [PATCH] Refs #349 Added functionality for TFTP installation and configuration --- installer/ogboot_installer.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/installer/ogboot_installer.py b/installer/ogboot_installer.py index 8ebf8df..64bd239 100755 --- a/installer/ogboot_installer.py +++ b/installer/ogboot_installer.py @@ -24,7 +24,7 @@ OPENGNSYS_SERVER = "opengnsys.es" CHECKPKG="" WORKDIR="/tmp/ogboot_installer" BRANCH = sys.argv[1] if len(sys.argv) > 1 else "main" -TFTPSERV = "tftp" # Define the TFTPSERV variable with the appropriate value +TFTPSERV = "tftpd-hpa" # Define the TFTPSERV variable with the appropriate value GIT_REPO="ssh://git@ognproject.evlt.uma.es:21987/opengnsys/ogboot.git" #DOWNLOAD_URL = f"https://{OPENGNSYS_SERVER}/trac/downloads" if os.path.isdir(f"{PROGRAM_DIR}/../installer"): @@ -44,8 +44,10 @@ else: STARTSERVICE = "/etc/init.d/$service restart" STOPSERVICE = "/etc/init.d/$service stop" -ENABLESERVICE = "update-rc.d $service defaults" -DISABLESERVICE = "update-rc.d $service disable" +#ENABLESERVICE = "update-rc.d $service defaults" +#DISABLESERVICE = "update-rc.d $service disable" +ENABLESERVICE = "systemctl enable $service.service" +DISABLESERVICE = "systemctl disable $service.service" APACHESERV = "apache2" APACHECFGDIR = "/etc/apache2" APACHESITESDIR = "sites-available" @@ -60,6 +62,10 @@ SAMBASERV = "smbd" SAMBACFGDIR = "/etc/samba" TFTPCFGDIR = "/var/lib/tftpboot" PHPFPMSERV = "php7.2-fpm" +INETDCFGDIR = "/etc/xinetd.d/" +INETDSERV = "xinetd" +OPENGNSYS_CLIENT_PASSWD="passusuog" +OPENGNSYS_CLIENT_USER="usuog" required_packages_18 = [ "apache2", "arp-scan", "automake", "build-essential", "btrfs-progs", "composer", "curl", "ctorrent", @@ -230,8 +236,6 @@ def autoConfigure(): # CHECKPKG = "dpkg -s $package 2>/dev/null | grep Status | grep -qw install" # STARTSERVICE = "service $service restart" if subprocess.call(['which', 'service'], stdout=subprocess.DEVNULL) == 0 else "/etc/init.d/$service restart" # STOPSERVICE = "service $service stop" if subprocess.call(['which', 'service'], stdout=subprocess.DEVNULL) == 0 else "/etc/init.d/$service stop" - # ENABLESERVICE = "systemctl enable $service.service" - # DISABLESERVICE = "systemctl disable $service.service" # APACHESERV = "apache2" # APACHECFGDIR = "/etc/apache2" # APACHESITESDIR = "sites-available" @@ -278,9 +282,8 @@ 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}" def create_ogboot_project(path_opengnsys_base): - # Cambia al usuario ogboot y crea el proyecto Symfony - subprocess.run(["composer", "create-project", "symfony/website-skeleton", path_opengnsys_base]) - # Elimina el archivo composer.lock + subprocess.run(["sudo", "useradd", "-m", "ogboot"]) + subprocess.run(["composer", "create-project", "--no-interaction", "symfony/website-skeleton", path_opengnsys_base], user="root") subprocess.run(["rm", f"{path_opengnsys_base}/composer.lock"]) print("Esqueleto de la aplicación creado y archivo composer.lock eliminado.") @@ -439,15 +442,15 @@ def tftpConfigure(): file.truncate() else: service = TFTPSERV - subprocess.run([ENABLESERVICE]) - subprocess.run([STARTSERVICE]) + subprocess.run(["systemctl", "enable", f"{service}.service"]) + subprocess.run(["systemctl", "start", f"{service}.service"]) service = INETDSERV - subprocess.run([ENABLESERVICE]) - subprocess.run([STARTSERVICE]) + subprocess.run(["systemctl", "enable", f"{service}.service"]) + subprocess.run(["systemctl", "start", f"{service}.service"]) # comprobamos el servicio tftp time.sleep(1) - testPxe() + #testPxe() def smbConfigure(): echoAndLog(f"{smbConfigure.__name__}(): Configuring Samba service.") @@ -515,7 +518,7 @@ if os.system("echo $?") != 0: exit(1) # Configuración de TFTP. -#tftpConfigure() +tftpConfigure() # Configuración de Samba. #smbConfigure()