From bd56977510baa5dc38b65d4c83a43c779467f4a2 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Wed, 14 Aug 2024 14:57:25 +0200 Subject: [PATCH] refs #596 move 02-boottoolsFsOpengnsys to a function, rename functions, reorganise code and config --- 02-boottoolsFsOpengnsys.py | 61 ---------------- 05-boottoolsFsLocales.py | 4 +- boottoolsfunctions/__init__.py | 38 ++++++++++ boottoolsgenerator.cfg | 128 ++++++++++++++++----------------- boottoolsgenerator.py | 105 ++++++++++----------------- 5 files changed, 142 insertions(+), 194 deletions(-) delete mode 100755 02-boottoolsFsOpengnsys.py diff --git a/02-boottoolsFsOpengnsys.py b/02-boottoolsFsOpengnsys.py deleted file mode 100755 index 0063f29..0000000 --- a/02-boottoolsFsOpengnsys.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/python3 - -import os -import logging -import subprocess -import shutil -import argparse - -svnclientdir = '/tmp/opengnsys/oglive_builder' -svnclientstructure = '/tmp/opengnsys/shared' -svnclientengine = '/tmp/opengnsys/engine' - -def boottoolsFsOpengnsys (ogclientmount, osdistrib, oscodename, osrelease, osarch, oshttp): - print (':'.join ([osdistrib, oscodename, osrelease, osarch, oshttp])) - print ('Iniciando la personalización con datos del repositorio') - - sources_list_in = f'{svnclientdir}/includes/etc/apt/sources.list.{osdistrib.lower()}' - sources_list_out = f'{svnclientdir}/includes/etc/apt/sources.list' - fdin = open (sources_list_in, 'r') - fdout = open (sources_list_out, 'w') - while True: - l = fdin.readline() - if not l: break - fdout.write (l.replace ('OSCODENAME', oscodename)) - fdin.close() - fdout.close() - - subprocess.run (f'chmod -R 775 {svnclientdir}/includes/usr/bin/*', shell=True) - - os.makedirs (f'{ogclientmount}/opt/opengnsys/lib/engine/bin/', exist_ok=True) - os.makedirs (f'{ogclientmount}/usr/local/etc', exist_ok=True) - os.makedirs (f'{ogclientmount}/usr/local/lib', exist_ok=True) - os.makedirs (f'{ogclientmount}/usr/local/plugins', exist_ok=True) - - subprocess.run (f'rsync -aH {svnclientdir}/includes/* {ogclientmount}/' , shell=True) - subprocess.run (f'rsync -aH {svnclientstructure}/* {ogclientmount}/opt/opengnsys/' , shell=True) - subprocess.run (f'rsync -aH {svnclientengine}/* {ogclientmount}/opt/opengnsys/lib/engine/bin/', shell=True) - - if not os.path.exists (f'{ogclientmount}/etc/pci.ids'): - shutil.copy (f'{svnclientstructure}/lib/pci.ids', f'{ogclientmount}/etc/') - - # Dependencias Qt para el Browser. - subprocess.run (f'rsync -aH {svnclientstructure}/etc/*.qmap {ogclientmount}/usr/local/etc', shell=True) - subprocess.run (f'rsync -aH {svnclientstructure}/lib/qtlib/* {ogclientmount}/usr/local/lib', shell=True) - subprocess.run (f'rsync -aH {svnclientstructure}/lib/fonts {ogclientmount}/usr/local/lib', shell=True) - subprocess.run (f'rsync -aH {svnclientstructure}/lib/qtplugins/* {ogclientmount}/usr/local/plugins', shell=True) - - # Browser y ogAdmClient. - if os.path.exists (f'{svnclientstructure}/bin/browser'): shutil.copy (f'{svnclientstructure}/bin/browser', f'{ogclientmount}/bin/') - if os.path.exists (f'{svnclientstructure}/bin/ogAdmClient'): shutil.copy (f'{svnclientstructure}/bin/ogAdmClient', f'{ogclientmount}/bin/') - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - parser.add_argument ('--mntpt', help='rootfs mount point', action='store', required=True) - parser.add_argument ('--osdistrib', help='OS distribution', action='store', required=True) - parser.add_argument ('--oscodename', help='OS codename', action='store', required=True) - parser.add_argument ('--osrelease', help='OS release', action='store', required=True) - parser.add_argument ('--osarch', help='OS architecture', action='store', required=True) - parser.add_argument ('--oshttp', help='OS HTTP source', action='store', required=True) - args = parser.parse_args() - boottoolsFsOpengnsys (args.mntpt, args.osdistrib, args.oscodename, args.osrelease, args.osarch, args.oshttp) diff --git a/05-boottoolsFsLocales.py b/05-boottoolsFsLocales.py index bb4e500..2d04c60 100755 --- a/05-boottoolsFsLocales.py +++ b/05-boottoolsFsLocales.py @@ -11,5 +11,5 @@ debconf_settings2 = config['General'].get ('debconf_settings2') subprocess.run (['debconf-set-selections'], input=debconf_settings2, text=True) -os.environ['DEBIAN_FRONTEND'] = 'noninteractive' -_run (['dpkg-reconfigure', 'console-setup', 'locales']) +## despues de esto, debconf-get-selections devuelve los valores antiguos, no se por que... +_run (['dpkg-reconfigure', '--frontend', 'noninteractive', 'console-setup', 'locales']) diff --git a/boottoolsfunctions/__init__.py b/boottoolsfunctions/__init__.py index c3aad00..592daff 100644 --- a/boottoolsfunctions/__init__.py +++ b/boottoolsfunctions/__init__.py @@ -311,6 +311,44 @@ def btogSetFsBase (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp): logger.info (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ok') return 0 +def boottoolsFsOpengnsys (builder, og_shared, og_engine, ogclientmount, osdistrib, oscodename): + print ('Iniciando la personalización con datos del repositorio') + + sources_list_in = f'{builder}/includes/etc/apt/sources.list.{osdistrib.lower()}' + sources_list_out = f'{builder}/includes/etc/apt/sources.list' + fdin = open (sources_list_in, 'r') + fdout = open (sources_list_out, 'w') + while True: + l = fdin.readline() + if not l: break + fdout.write (l.replace ('OSCODENAME', oscodename)) + fdin.close() + fdout.close() + + subprocess.run (f'chmod -R 775 {builder}/includes/usr/bin/*', shell=True) + + os.makedirs (f'{ogclientmount}/opt/opengnsys/lib/engine/bin/', exist_ok=True) + os.makedirs (f'{ogclientmount}/usr/local/etc', exist_ok=True) + os.makedirs (f'{ogclientmount}/usr/local/lib', exist_ok=True) + os.makedirs (f'{ogclientmount}/usr/local/plugins', exist_ok=True) + + subprocess.run (f'rsync -aH {builder}/includes/* {ogclientmount}/' , shell=True) + subprocess.run (f'rsync -aH {og_shared}/* {ogclientmount}/opt/opengnsys/' , shell=True) + subprocess.run (f'rsync -aH {og_engine}/* {ogclientmount}/opt/opengnsys/lib/engine/bin/', shell=True) + + if not os.path.exists (f'{ogclientmount}/etc/pci.ids'): + shutil.copy (f'{og_shared}/lib/pci.ids', f'{ogclientmount}/etc/') + + # Dependencias Qt para el Browser. + subprocess.run (f'rsync -aH {og_shared}/etc/*.qmap {ogclientmount}/usr/local/etc', shell=True) + subprocess.run (f'rsync -aH {og_shared}/lib/qtlib/* {ogclientmount}/usr/local/lib', shell=True) + subprocess.run (f'rsync -aH {og_shared}/lib/fonts {ogclientmount}/usr/local/lib', shell=True) + subprocess.run (f'rsync -aH {og_shared}/lib/qtplugins/* {ogclientmount}/usr/local/plugins', shell=True) + + # Browser y ogAdmClient. + if os.path.exists (f'{og_shared}/bin/browser'): shutil.copy (f'{og_shared}/bin/browser', f'{ogclientmount}/bin/') + if os.path.exists (f'{og_shared}/bin/ogAdmClient'): shutil.copy (f'{og_shared}/bin/ogAdmClient', f'{ogclientmount}/bin/') + def boottoolsSshServer (btrootfsmnt): if not os.path.exists ('/root/.ssh/id_rsa'): ## crea un par de claves en la VM, no en el chroot _run (['ssh-keygen', '-q', '-f', '/root/.ssh/id_rsa', '-N', '']) diff --git a/boottoolsgenerator.cfg b/boottoolsgenerator.cfg index c6eeda8..018996a 100644 --- a/boottoolsgenerator.cfg +++ b/boottoolsgenerator.cfg @@ -1,67 +1,3 @@ -[Packages] - -basic = - dialog man-db fbset gdebi-core bash-static busybox-static locales lshw gawk git python3-openssl python3 php-cli dmidecode rpm sqlite3 os-prober moreutils jq - #console-data # ogLive anterior a Ubuntu 20.04 - #subversion # ogLive anterior a Ubuntu 18.04 - #php5-cli # ogLive anterior a Ubuntu 16.04 - #realpath # ogLive hasta Ubuntu 16.04 - #zypper # PROBAR - -cloning = fsarchiver pv - #pxe-kexec # ubuntu noble: Unable to locate package - mbuffer parted gdisk chntpw clonezilla registry-tools reglookup libparse-win32registry-perl libwin-hivex-perl grokevt libhivex0 libhivex-bin rsync - -compile = - build-essential libattr1 libattr1-dev uuid-dev attr make m4 gettext libmhash-dev - #libattr* # Satura el tamaño del archivo en Ubuntu 15.04 - -compressor = lzma zip unzip gzip lzop pigz pbzip2 lbzip2 rzip p7zip-full - -filesystem_local = - squashfs-tools unionfs-fuse ntfs-3g dosfstools fatresize - #exfat-utils # ubuntu noble: has no installation candidate - dmraid dmsetup lvm2 e2fsprogs - jfsutils reiserfsprogs reiser4progs xfsprogs mhddfs hfsplus hfsprogs hfsutils nilfs-tools vmfs-tools - btrfs-progs # ogLive a partir de Ubuntu 20.04 - zfsutils-linux # ogLive a partir de Ubuntu 16.04 - android-tools-adb # ogLive a partir de Ubuntu 16.04 - android-tools-fastboot # ogLive a partir de Ubuntu 16.04 - f2fs-tools - #drbl-ntfsprogs # Eliminado - #ntfs-config # ogLive anterior a Ubuntu 20.04 - #btrfs-tools # ogLive anterior a Ubuntu 20.04 - #ufsutils # ogLive anterior a Ubuntu 14.04 - #zfsutils # ogLive anterior a Ubuntu 16.04 - #android-tools-fsutils # ogLive entre Ubuntu 16.04 y Ubuntu 20.04 - -filesystem_remote = - sshfs cifs-utils smbclient open-iscsi openssh-server - #nfs-common # Provoca error de instalación en Ubuntu 15.04 - #bittornado # ogLive anterior a Ubuntu 20.04 - -monitoring = htop ncdu bwbar bmon iftop ifstat dstat hdparm sdparm blktool testdisk - -networking = netpipes curl wget tftp-hpa dnsutils - #trickle # ubuntu noble: has no installation candidate - lighttpd ethtool ssmping tcpdump nmap arping ntpdate ctorrent udpcast #iptraf - -testing = - screen schroot xmlstarlet - efibootmgr efitools refind grub-efi-amd64-bin grub-efi-ia32-bin grub-pc-bin ## UEFI - #libxss1 python-prctl python-six python-requests ## OGAgent - ############## - fusioninventory-agent nvme-cli disktype laptop-detect - #discover casper lupin-casper xinit obconf xserver-xorg x11-xserver-utils xterm network-manager-gnome plymouth-x11 plymouth-label plymouth-theme-ubuntu-logo pcmanfm chromium-browser gtk-theme-switch gtk2-engines murrine-themes - ####################################3 - #gnome-icon-theme gnome-brave-icon-theme dmz-cursor-theme python-wnck python-xlib python-pyinotify python-alsaaudio python-vte maximus gpicview leafpad lxappearance lxmenu-data lxrandr lxterminal nitrogen ttf-ubuntu-font-family time synaptic libglib-perl libgtk2-perl libxml-simple-perl smartmontools gnome-disk-utility policykit-1-gnome policykit-desktop-privileges baobab lshw-gtk usb-creator-gtk wodim curlftpfs libnotify-bin cryptsetup system-config-lvm - -xwindows = - v86d # VESA Kernel 3.7+ - #xorg-dev xorg lxde #+300M - #roxterm gparted #+80M - #openbox midori #xvesa en compilacion - [General] logging_level = INFO @@ -130,3 +66,67 @@ isolinux_template = MENU LABEL pxe KERNEL /clonezilla/live/vmlinuz1 APPEND initrd=/clonezilla/live/initrd1.img boot=live union=aufs noswap vga=788 ip=frommedia + +[Packages] + +basic = + dialog man-db fbset gdebi-core bash-static busybox-static locales lshw gawk git python3-openssl python3 php-cli dmidecode rpm sqlite3 os-prober moreutils jq + #console-data # ogLive anterior a Ubuntu 20.04 + #subversion # ogLive anterior a Ubuntu 18.04 + #php5-cli # ogLive anterior a Ubuntu 16.04 + #realpath # ogLive hasta Ubuntu 16.04 + #zypper # PROBAR + +cloning = fsarchiver pv + #pxe-kexec # ubuntu noble: Unable to locate package + mbuffer parted gdisk chntpw clonezilla registry-tools reglookup libparse-win32registry-perl libwin-hivex-perl grokevt libhivex0 libhivex-bin rsync + +compile = + build-essential libattr1 libattr1-dev uuid-dev attr make m4 gettext libmhash-dev + #libattr* # Satura el tamaño del archivo en Ubuntu 15.04 + +compressor = lzma zip unzip gzip lzop pigz pbzip2 lbzip2 rzip p7zip-full + +filesystem_local = + squashfs-tools unionfs-fuse ntfs-3g dosfstools fatresize + #exfat-utils # ubuntu noble: has no installation candidate + dmraid dmsetup lvm2 e2fsprogs + jfsutils reiserfsprogs reiser4progs xfsprogs mhddfs hfsplus hfsprogs hfsutils nilfs-tools vmfs-tools + btrfs-progs # ogLive a partir de Ubuntu 20.04 + zfsutils-linux # ogLive a partir de Ubuntu 16.04 + android-tools-adb # ogLive a partir de Ubuntu 16.04 + android-tools-fastboot # ogLive a partir de Ubuntu 16.04 + f2fs-tools + #drbl-ntfsprogs # Eliminado + #ntfs-config # ogLive anterior a Ubuntu 20.04 + #btrfs-tools # ogLive anterior a Ubuntu 20.04 + #ufsutils # ogLive anterior a Ubuntu 14.04 + #zfsutils # ogLive anterior a Ubuntu 16.04 + #android-tools-fsutils # ogLive entre Ubuntu 16.04 y Ubuntu 20.04 + +filesystem_remote = + sshfs cifs-utils smbclient open-iscsi openssh-server + #nfs-common # Provoca error de instalación en Ubuntu 15.04 + #bittornado # ogLive anterior a Ubuntu 20.04 + +monitoring = htop ncdu bwbar bmon iftop ifstat dstat hdparm sdparm blktool testdisk + +networking = netpipes curl wget tftp-hpa dnsutils + #trickle # ubuntu noble: has no installation candidate + lighttpd ethtool ssmping tcpdump nmap arping ntpdate ctorrent udpcast #iptraf + +testing = + screen schroot xmlstarlet + efibootmgr efitools refind grub-efi-amd64-bin grub-efi-ia32-bin grub-pc-bin ## UEFI + #libxss1 python-prctl python-six python-requests ## OGAgent + ############## + fusioninventory-agent nvme-cli disktype laptop-detect + #discover casper lupin-casper xinit obconf xserver-xorg x11-xserver-utils xterm network-manager-gnome plymouth-x11 plymouth-label plymouth-theme-ubuntu-logo pcmanfm chromium-browser gtk-theme-switch gtk2-engines murrine-themes + ####################################3 + #gnome-icon-theme gnome-brave-icon-theme dmz-cursor-theme python-wnck python-xlib python-pyinotify python-alsaaudio python-vte maximus gpicview leafpad lxappearance lxmenu-data lxrandr lxterminal nitrogen ttf-ubuntu-font-family time synaptic libglib-perl libgtk2-perl libxml-simple-perl smartmontools gnome-disk-utility policykit-1-gnome policykit-desktop-privileges baobab lshw-gtk usb-creator-gtk wodim curlftpfs libnotify-bin cryptsetup system-config-lvm + +xwindows = + v86d # VESA Kernel 3.7+ + #xorg-dev xorg lxde #+300M + #roxterm gparted #+80M + #openbox midori #xvesa en compilacion diff --git a/boottoolsgenerator.py b/boottoolsgenerator.py index fc2faf6..2dc47ca 100755 --- a/boottoolsgenerator.py +++ b/boottoolsgenerator.py @@ -10,7 +10,7 @@ import shutil curdir = os.path.dirname (__file__) sys.path.insert (0, curdir) -from boottoolsfunctions import _run, _mount, _umount, _read_config, btogGetOsInfo1, btogGetOsInfo2, btogGetVar, btogSetFsVirtual, btogSetFsAccess, btogSetFsBase, boottoolsSshServer, boottoolsSshClient, btogFsInitrd, btogFsSqfs, btogIsoGenerator +from boottoolsfunctions import _run, _mount, _umount, _read_config, btogGetOsInfo1, btogGetOsInfo2, btogGetVar, btogSetFsVirtual, btogSetFsAccess, btogSetFsBase, boottoolsFsOpengnsys, boottoolsSshServer, boottoolsSshClient, btogFsInitrd, btogFsSqfs, btogIsoGenerator def _logging(): #logging.root.handlers = [] @@ -36,7 +36,10 @@ def clone_client_dirs (ogrepo_url, ogrepo_branch, ogrepo_dir): def _mount_rootfs(): global btrootfsimg, btrootfsmnt - _mount (btrootfsimg, btrootfsmnt, opts=['-o', 'loop,offset=32256']) + try: _mount (btrootfsimg, btrootfsmnt, opts=['-o', 'loop,offset=32256']) + except: + logger.error ('mount failed') + sys.exit (1) def _get_pxepkg(): #grep "http://free.nchc.org.tw/drbl-core" /etc/apt/sources.list || echo "deb http://free.nchc.org.tw/drbl-core drbl stable" >> /etc/apt/sources.list @@ -77,10 +80,7 @@ def _debootstrap(): cp = subprocess.run (['schroot', '--chroot', 'IMGogclient', '--', 'stat', '/etc']) if (cp.returncode): logger.debug (f'schroot returned code "{cp.returncode}", calling btogSetFsBase()') - try: _mount_rootfs() - except: - logger.error ('mount failed') - sys.exit (1) + _mount_rootfs() try: btogSetFsBase (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp) except Exception as e: logger.error (str (e)) @@ -92,83 +92,61 @@ def _initramfs_version (gitrelease, osrelease, btdir): #sed -i "1 s/$/ $GITRELEASE ($OSRELEASE)/" ${BTDIR}/includes/etc/initramfs-tools/scripts/VERSION.txt _run (['sed', '-i', f'1 s/$/ {gitrelease} ({osrelease})/', f'{btdir}/includes/etc/initramfs-tools/scripts/VERSION.txt']) -def _cerodos(): - try: _mount_rootfs() - except: - logger.error ('mount failed') - sys.exit (1) - - logger.debug (f'running \'{curdir}/02-boottoolsFsOpengnsys.py --mntpt "{btrootfsmnt}" --osdistrib "{osdistrib}" --oscodename "{oscodename}" --osrelease "{osrelease}" --osarch "{osarch}" --oshttp "{oshttp}"\'') - stdout, _ = _run ([f'{curdir}/02-boottoolsFsOpengnsys.py', '--mntpt', btrootfsmnt, '--osdistrib', osdistrib, '--oscodename', oscodename, '--osrelease', osrelease, '--osarch', osarch, '--oshttp', oshttp]) - logger.debug (f'02-boottoolsFsOpengnsys stdout follows:') - for i in stdout.strip().split('\n'): logger.debug (' ' + i) - +def _copy_files (btrootfsmnt, osdistrib, oscodename): + _mount_rootfs() + builder = '/tmp/opengnsys/oglive_builder' + og_shared = '/tmp/opengnsys/shared' + og_engine = '/tmp/opengnsys/engine' + boottoolsFsOpengnsys (builder, og_shared, og_engine, btrootfsmnt, osdistrib, oscodename) _umount (btrootfsmnt) -def _chroot_cerotres(): +def _install_compile_software (curdir, osrelease, osarch): logger.info ('Fase 5.1 instalar paquetes deb con apt-get') logger.debug (f'running \'schroot --chroot IMGogclient -- {curdir}/03-boottoolsSoftwareInstall.py --osrelease "{osrelease}" --osarch "{osarch}"\'') stdout, _ = _run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/03-boottoolsSoftwareInstall.py', '--osrelease', osrelease, '--osarch', osarch]) logger.debug (f'03-boottoolsSoftwareInstall stdout follows:') for i in stdout.strip().split('\n'): logger.debug (' ' + i) -def _chroot_cerocuatro(): logger.info ('Fase 5.2 compilar software.') - logger.debug ('running \'schroot --chroot IMGogclient -- {}/04-boottoolsSoftwareCompile.py\'') - #cd / + logger.debug (f'running \'schroot --chroot IMGogclient -- {curdir}/04-boottoolsSoftwareCompile.py\'') stdout, _ = _run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/04-boottoolsSoftwareCompile.py']) - #cd - logger.debug (f'04-boottoolsSoftwareCompile stdout follows:') for i in stdout.strip().split('\n'): logger.debug (' ' + i) -def _ssh_stuff(): - logger.info ('Fase 6.1 Configurar ssh') - try: _mount_rootfs() - except: - logger.error ('mount failed') - sys.exit (1) - - #cd / - #schroot --chroot IMGogclient -- /usr/bin/boot-tools/boottoolsSshServer.sh ## no necesita chroot - boottoolsSshServer (btrootfsmnt) - #cd - - - #schroot --chroot IMGogclient -- /usr/bin/boot-tools/boottoolsSshClient.sh ## no necesita chroot - boottoolsSshClient (btrootfsmnt) - - _umount (btrootfsmnt) - - ## el resultado es: - ## - hay un nuevo par de claves en la VM /root/.ssh - ## - hay otro nuevo par de claves en el rootfs /var/lib/tftpboot/ogclient/ogclientmount/root/.ssh - ## - las dos claves públicas (una de cada par) están autorizadan en el rootfs /var/lib/tftpboot/ogclient/ogclientmount/root/.ssh/authorized_keys - -def _chroot_cerocinco(): - logger.info ('Fase 6.2 Configurar las locales') +def _debconf2 (curdir): + logger.info ('Fase 6.1 Configurar las locales') logger.debug (f'running \'schroot --chroot IMGogclient -- {curdir}/05-boottoolsFsLocales.py\'') stdout, _ = _run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/05-boottoolsFsLocales.py']) logger.debug (f'05-boottoolsFsLocales stdout follows:') for i in stdout.strip().split('\n'): logger.debug (' ' + i) -def _chroot_ceroseis(): - logger.info ('Fase 6.3 Crear initrd') ## what?? - #cd / - #schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsInitrdGenerate.sh + logger.info ('Fase 6.3 Crear initrd') logger.debug (f'running \'schroot --chroot IMGogclient -- {curdir}/06-boottoolsInitrdGenerate.py --osrelease "{osrelease}"\'') stdout, _ = _run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/06-boottoolsInitrdGenerate.py', '--osrelease', osrelease]) logger.debug (f'06-boottoolsInitrdGenerate stdout follows:') for i in stdout.strip().split('\n'): logger.debug (' ' + i) ## esto deja initrd.img-6.8.0-31-generic y vmlinuz-6.8.0-31-generic en /tmp -def _mkinitrd (bttargetdir, osrelease): - logger.info ('Fase 7.1 Generar el initrd') ## what?? +def _ssh_stuff(): + logger.info ('Fase 6.2 Configurar ssh') + _mount_rootfs() + boottoolsSshServer (btrootfsmnt) + boottoolsSshClient (btrootfsmnt) + _umount (btrootfsmnt) + ## el resultado es: + ## - hay un nuevo par de claves en la VM /root/.ssh + ## - hay otro nuevo par de claves en el rootfs /var/lib/tftpboot/ogclient/ogclientmount/root/.ssh + ## - las dos claves públicas (una de cada par) están autorizadan en el rootfs /var/lib/tftpboot/ogclient/ogclientmount/root/.ssh/authorized_keys + +def _mkinitrd_squashfs_isofs (bttargetdir, osrelease, btrootfsmnt, pxepkg, isolinux_tpl nameisoclient): + logger.info ('Fase 7.1 Copiar el initrd a su sitio') + _mount_rootfs() btogFsInitrd (bttargetdir, osrelease) -def _mksquashfs (bttargetdir, btrootfsmnt): logger.info ('Fase 7.2 Generar fichero sqfs a partir del fichero img') btogFsSqfs (bttargetdir, btrootfsmnt) + _umount (btrootfsmnt) -def _mkisofs (pxepkg, isolinux_tpl, bttargetdir, nameisoclient): logger.info ('Fase 7.3 Generar la ISO') btogIsoGenerator (pxepkg, isolinux_tpl, bttargetdir, nameisoclient) @@ -200,6 +178,8 @@ osdistrib, oscodename, osrelease, osarch, oshttp = btogGetOsInfo1(type_client) btdir, bttargetdir, btrootfsimg, btrootfsmnt, btrootfsimglabel, log_file, versionboottools, btvirtualdisksize = btogGetVar(osarch) gitrelease, nameisoclient, namehostclient = btogGetOsInfo2(ogrepo_dir, versionboottools, oscodename, osrelease, osarch) +logger.info (':'.join ([osdistrib, oscodename, osrelease, osarch, oshttp])) + ## this is convenient in case the previous run failed and we want to run this program again try: _umount (btrootfsmnt) except: pass @@ -215,25 +195,16 @@ _debootstrap() logger.info ('FASE 4 - Incorporando ficheros OpenGnsys al sistema raíz rootfs') _initramfs_version (gitrelease, osrelease, btdir) -_cerodos() +_copy_files (btrootfsmnt, osdistrib, oscodename, osrelease, osarch, oshttp) logger.info ('FASE 5 - Instalar software') -_chroot_cerotres() -_chroot_cerocuatro() +_install_compile_software (curdir, osrelease, osarch) logger.info ('FASE 6 - Personalizar el sistema creado') +_debconf2 (curdir) _ssh_stuff() -_chroot_cerocinco() -_chroot_ceroseis() logger.info ('FASE 7 - Generar distribucion') -_mkinitrd (bttargetdir, osrelease) -try: _mount_rootfs() -except: - logger.error ('mount failed') - sys.exit (1) -_mksquashfs (bttargetdir, btrootfsmnt) -_umount (btrootfsmnt) -_mkisofs (pxepkg, isolinux_tpl, bttargetdir, nameisoclient) +_mkinitrd_squashfs_isofs (bttargetdir, osrelease, btrootfsmnt, pxepkg, isolinux_tpl nameisoclient) logger.info ('OpenGnsys installation finished')