source: ogLive-Builder-Git/boottools/btog.py @ ed7eb92

filebeat-installer
Last change on this file since ed7eb92 was 1ee274b, checked in by Natalia Serrano <natalia.serrano@…>, 2 months ago

refs #1614 fix whitespace

  • Property mode set to 100644
File size: 19.8 KB
RevLine 
[c6cf378]1import platform
2import os
3import time
4import logging
5import subprocess
[acc32a2]6import shutil
7import glob
[be59919]8import datetime
[c6cf378]9
[95a24ac]10from . import utils
[c6cf378]11
[1bd24c9]12logger = logging.getLogger ('boottools')
13
14def GetVar (osarch):
[c6cf378]15    bttargetdir      = '/var/lib/tftpboot/ogclient/'
16    btrootfsimg      = os.path.join (bttargetdir, 'ogclient.img')
17    btrootfsmnt      = os.path.join (bttargetdir, 'ogclientmount')
18    if 'i386' == osarch:
19        btvirtualdisksize = '2000'    # tamaño maximo limitado por schroot 2GB para 32 bits
20    else:
[4101da8]21        btvirtualdisksize = '5G'
[5ecf9f3]22    return bttargetdir, btrootfsimg, btrootfsmnt, btvirtualdisksize
[c6cf378]23
[c79d715]24def GetOsInfo (type_client='host'):
[c6cf378]25    if 'precise' == type_client:        # ogLive 1.0.4-rc2 basado en Ubuntu 12.04 LTS.
26            osdistrib='ubuntu'
27            oscodename='precise'
28            osrelease='3.2.0-23-generic'
29            osarch='i386'
30            oshttp='http://es.archive.ubuntu.com/ubuntu/'
31    elif 'wheezy' == type_client:       # ogLive basado en Debian 7.3.
32            osdistrib='debian'
33            oscodename='wheezy'
34            osrelease='3.2.0-4-i386'
35            osarch='i386'
36            oshttp='http://ftp.es.debian.org/debian/'
37    elif 'quantal' == type_client:      # ogLive 1.0.5-rc2 basado en Ubuntu 12.10 con Kernel descargado.
38            osdistrib='ubuntu'
39            oscodename='quantal'
40            osrelease='3.7.6-030706-generic'
41            osarch='i386'
42            oshttp='http://es.archive.ubuntu.com/ubuntu/'
43    elif 'raring' == type_client:       # ogLive 1.0.5-rc3 basado en Ubuntu 13.04.
44            osdistrib='ubuntu'
45            oscodename='raring'
46            osrelease='3.8.0-22-generic'
47            osarch='i386'
48            oshttp='http://es.archive.ubuntu.com/ubuntu/'
49    elif 'trusty' == type_client:       # ogLive 1.0.5-rc4 basado en Ubuntu 14.04.
50            osdistrib='ubuntu'
51            oscodename='trusty'
52            osrelease='3.13.0-24-generic'
53            osarch='i386'
54            oshttp='http://es.archive.ubuntu.com/ubuntu/'
55    elif 'vivid' == type_client:                # ogLive 1.1.0-rc2 basado en Ubuntu 15.04.
56            osdistrib='ubuntu'
57            oscodename='vivid'
58            osrelease='3.19.0-49-generic'
59            osarch='i386'
60            oshttp='http://es.archive.ubuntu.com/ubuntu/'
61    elif 'wily' == type_client:                 # ogLive 1.1.0-rc1 basado en Ubuntu 15.10.
62            osdistrib='ubuntu'
63            oscodename='wily'
64            osrelease='4.2.0-35-generic'
65            osarch='i386'
66            oshttp='http://es.archive.ubuntu.com/ubuntu/'
67    elif 'xenial' == type_client or 'xenial-4.4' == type_client:        # ogLive 1.1.0-rc4 basado en Ubuntu 16.04 y Kernel 4.4.
68            osdistrib='ubuntu'
69            oscodename='xenial'
70            osrelease='4.4.0-34-generic'
71            osarch='i386'
72            oshttp='http://es.archive.ubuntu.com/ubuntu/'
73    elif 'xenial-4.8' == type_client:   # ogLive 1.1.0-rc5 basado en Ubuntu 16.04 y Kernel 4.8.
74            osdistrib='ubuntu'
75            oscodename='xenial'
76            osrelease='4.8.0-39-generic'
77            osarch='amd64'
78            oshttp='http://es.archive.ubuntu.com/ubuntu/'
79    elif 'xenial-4.13' == type_client:  # ogLive 1.1.0-rc6 basado en Ubuntu 16.04 y Kernel 4.13.
80            osdistrib='ubuntu'
81            oscodename='xenial'
82            osrelease='4.13.0-17-generic'
83            osarch='amd64'
84            oshttp='http://es.archive.ubuntu.com/ubuntu/'
85    elif 'bionic' == type_client or 'bionic-4.15' == type_client:       # ogLive 1.1.1-rc1 basado en Ubuntu 18.04 y Kernel 4.15.
86            osdistrib='ubuntu'
87            oscodename='bionic'
88            osrelease='4.15.0-32-generic'
89            osarch='amd64'
90            oshttp='http://es.archive.ubuntu.com/ubuntu/'
91    elif 'bionic-4.18' == type_client:  # ogLive 1.1.1-rc3 basado en Ubuntu 18.04 y Kernel 4.18.
92            osdistrib='ubuntu'
93            oscodename='bionic'
94            osrelease='4.18.0-20-generic'
95            osarch='amd64'
96            oshttp='http://es.archive.ubuntu.com/ubuntu/'
97    elif 'bionic-5.0' == type_client:   # ogLive 1.1.1-rc5 basado en Ubuntu 18.04 y Kernel 5.0.
98            osdistrib='ubuntu'
99            oscodename='bionic'
100            osrelease='5.0.0-27-generic'
101            osarch='amd64'
102            oshttp='http://es.archive.ubuntu.com/ubuntu/'
103    elif 'focal' == type_client:        # ogLive 1.2.0-rc1 basado en Ubuntu 20.04 y Kernel 5.4.
104            osdistrib='ubuntu'
105            oscodename='focal'
106            osrelease='5.4.0-42-generic'
107            osarch='amd64'
108            oshttp='http://es.archive.ubuntu.com/ubuntu/'
[723a79f]109    elif 'noble' == type_client:        # ogLive 3.1.1 basado en Ubuntu 24.04 y Kernel 6.8.
[ec2ab82]110            osdistrib='ubuntu'
111            oscodename='noble'
112            osrelease='6.8.0-31-generic'
113            osarch='amd64'
114            oshttp='http://es.archive.ubuntu.com/ubuntu/'
[c6cf378]115    elif 'host' == type_client: # ogLive basado en la distribución del servidor.
116            osdistrib=platform.freedesktop_os_release()['NAME']
117            oscodename=platform.freedesktop_os_release()['VERSION_CODENAME']
118            osrelease=platform.uname()[2]
[95a24ac]119            osarch, _=utils.run (['dpkg', '--print-architecture'])
[c6cf378]120            oshttp='http://es.archive.ubuntu.com/ubuntu/'
121    else:       # Parámetro desconocido
[bb2d57b]122            logger.error ('Parámetro no válido.')
123            osdistrib=None
124            oscodename=None
125            osrelease=None
126            osarch=None
127            oshttp=None
[0371870]128    return osdistrib, oscodename, osrelease, osarch, oshttp
[c6cf378]129
[d1822ec]130def mkrootfs (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize, bttargetdir, osarch):
[c5e9f68]131    logger.info (f'Creación y formateo del disco virtual "{btrootfsimg}" "{btvirtualdisksize}" MB')
[c6cf378]132
[95a24ac]133    try: utils.umount (btrootfsmnt)
[acc32a2]134    except: pass
[c6cf378]135
[95a24ac]136    if (utils.is_mounted (btrootfsmnt)):
[c5e9f68]137        raise Exception (f'failed to umount "{btrootfsmnt}"')
[c6cf378]138
[acc32a2]139    try: os.makedirs (btrootfsmnt, exist_ok=True)
140    except:
[c5e9f68]141        raise Exception (f'Creando directorio "{btrootfsmnt}" : ERROR')
[c6cf378]142
[95a24ac]143    try: utils.run (['chown', '-R', 'root:opengnsys', bttargetdir])
[c2fe8f7]144    except Exception as e:
145        raise Exception (f'Failed to chown root:opengnsys "{btrootfsmnt}": {str(e)}')
[c6cf378]146
[c5e9f68]147    logger.info (f'Creating disk image "{btrootfsimg}"')
[c6cf378]148    if 'i386' == osarch:
[95a24ac]149        try: utils.run (['dd', 'if=/dev/zero', f'of={btrootfsimg}', 'bs=1048576', f'count={btvirtualdisksize}'])
[c2fe8f7]150        except Exception as e:
151            raise Exception (f'Creando el disco virtual "{btrootfsimg}" con tamaño maxima "{btvirtualdisksize}" MB : ERROR: {str(e)}')
[c6cf378]152    else:
[95a24ac]153        try: utils.run (['qemu-img', 'create', btrootfsimg, btvirtualdisksize])
[c2fe8f7]154        except Exception as e:
155            raise Exception (f'Creando el disco virtual "{btrootfsimg}" con tamaño maxima "{btvirtualdisksize}" MB : ERROR: {str(e)}')
[c6cf378]156
[acc32a2]157    logger.debug ('losetup --find')
[95a24ac]158    diskloop, _ = utils.run (['losetup', '--find'])
[c6cf378]159    if not diskloop:
[acc32a2]160        raise Exception ('no diskloop')
[c6cf378]161
[acc32a2]162    logger.debug ('losetup attach')
[95a24ac]163    try: utils.run (['losetup', '--partscan', diskloop, btrootfsimg])
[acc32a2]164    except: raise Exception ('losetup failed')
[c6cf378]165
[acc32a2]166    logger.info ('Partitioning disk image')
[95a24ac]167    stdout, _ = utils.run (['bash', '-c', f"echo $'n\np\n1\n\n\nt\n83\nw' |fdisk {diskloop}"])
[c6cf378]168
[ec2ab82]169    time.sleep (3)
[acc32a2]170    logger.debug ('losetup --detach')
[95a24ac]171    try: utils.run (['losetup', '--detach', diskloop])
[c6cf378]172    except:
[acc32a2]173        raise Exception ('Liberando disco virtual despues del particionado: ERROR')
174
175    logger.debug ('losetup --find')
[95a24ac]176    partloop, _ = utils.run (['losetup', '--find'])
[acc32a2]177    if not partloop:
178        raise Exception ('no partloop')
[c6cf378]179
[acc32a2]180    logger.debug ('losetup --offset attach')
[95a24ac]181    utils.run (['losetup', '--offset', '32256', partloop, btrootfsimg])
[acc32a2]182
183    logger.info ('Creating ext4 filesystem')
[95a24ac]184    try: utils.run (['mkfs.ext4', '-b', '4096', '-L', btrootfsimglabel, partloop])
[c6cf378]185    except:
[acc32a2]186        raise Exception ('Formateando la particion principal del disco virtual: ERROR')
[c6cf378]187
[ec2ab82]188    time.sleep (3)
[acc32a2]189    logger.debug ('losetup --detach')
[95a24ac]190    try: utils.run (['losetup', '--detach', partloop])
[c6cf378]191    except:
[acc32a2]192        raise Exception ('Liberando la particion virtual despues del formateo: ERROR')
[c6cf378]193
[c5e9f68]194    logger.info (f'"{btrootfsimg}" "{btvirtualdisksize}" MB : OK')
[acc32a2]195
[0ab0e61]196# works on an already mounted rootfs
[53310a8]197def debootstrap (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp):
[acc32a2]198    logger.info ('Iniciando la generación del sistema de archivos')
199
200    logger.info ('debootstrapping system')
[c5e9f68]201    logger.debug (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}"')
[95a24ac]202    try: utils.run (['debootstrap', f'--arch={osarch}', '--components=main,universe', oscodename, btrootfsmnt, oshttp])
[c67b7f6]203    except: raise Exception (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ha fallado!')
[acc32a2]204
[c5e9f68]205    logger.info (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ok')
[acc32a2]206    return 0
[960b66e]207
[5dfeffb]208def copy_og_files (builder, og_shared, ogclientmount, osdistrib, oscodename):
[d1822ec]209    logger.info ('Iniciando la personalización con datos del repositorio')
[bd56977]210
211    sources_list_in  = f'{builder}/includes/etc/apt/sources.list.{osdistrib.lower()}'
212    sources_list_out = f'{builder}/includes/etc/apt/sources.list'
213    fdin  = open (sources_list_in,  'r')
214    fdout = open (sources_list_out, 'w')
215    while True:
216        l = fdin.readline()
217        if not l: break
218        fdout.write (l.replace ('OSCODENAME', oscodename))
219    fdin.close()
220    fdout.close()
221
222    subprocess.run (f'chmod -R 775 {builder}/includes/usr/bin/*', shell=True)
223
224    os.makedirs (f'{ogclientmount}/opt/opengnsys/lib/engine/bin/', exist_ok=True)
225    os.makedirs (f'{ogclientmount}/usr/local/etc',                 exist_ok=True)
226    os.makedirs (f'{ogclientmount}/usr/local/lib',                 exist_ok=True)
227    os.makedirs (f'{ogclientmount}/usr/local/plugins',             exist_ok=True)
228
[1ee274b]229    subprocess.run (f'rsync -aH {builder}/includes/* {ogclientmount}/'              , shell=True)
230    subprocess.run (f'rsync -aH {og_shared}/*        {ogclientmount}/opt/opengnsys/', shell=True)
[bd56977]231
232    if not os.path.exists (f'{ogclientmount}/etc/pci.ids'):
233        shutil.copy (f'{og_shared}/lib/pci.ids', f'{ogclientmount}/etc/')
234
235    # Dependencias Qt para el Browser.
236    subprocess.run (f'rsync -aH {og_shared}/etc/*.qmap      {ogclientmount}/usr/local/etc',     shell=True)
237    subprocess.run (f'rsync -aH {og_shared}/lib/qtlib/*     {ogclientmount}/usr/local/lib',     shell=True)
238    subprocess.run (f'rsync -aH {og_shared}/lib/fonts       {ogclientmount}/usr/local/lib',     shell=True)
239    subprocess.run (f'rsync -aH {og_shared}/lib/qtplugins/* {ogclientmount}/usr/local/plugins', shell=True)
240
[723a79f]241    # Browser
[1ee274b]242    if os.path.exists (f'{og_shared}/bin/browser'): shutil.copy (f'{og_shared}/bin/browser', f'{ogclientmount}/bin/')
[723a79f]243
[e60695f]244def sysctl (btrootfsmnt):
245    logger.debug ('copiando sysctl.conf')
246    with open (f'{btrootfsmnt}/etc/sysctl.conf', 'w') as fd:
247        fd.write ('net.ipv6.conf.all.disable_ipv6 = 1\n')
248        fd.write ('net.ipv6.conf.default.disable_ipv6 = 1\n')
249        fd.write ('net.ipv6.conf.lo.disable_ipv6 = 1\n')
250
[d1822ec]251def ssh_server (btrootfsmnt):
[0ab0e61]252    if not os.path.exists ('/root/.ssh/id_rsa'):                     ## creates a key pair in the VM (or docker container), not in the chroot
[95a24ac]253        utils.run (['ssh-keygen', '-q', '-f', '/root/.ssh/id_rsa', '-N', ''])
[960b66e]254
255    logger.debug ('comprobando directorio .ssh del root')
[0ab0e61]256    if not os.path.exists (f'{btrootfsmnt}/root/.ssh'):              ## creates directory within the chroot
[960b66e]257        logger.debug ('creando directorio .ssh 600')
[c5e9f68]258        os.mkdir (f'{btrootfsmnt}/root/.ssh')
259        os.chmod (f'{btrootfsmnt}/root/.ssh', 0o700)
[960b66e]260
[0ab0e61]261    logger.debug ('creando el fichero authorized_keys')              ## creates file within the chroot
[c5e9f68]262    if not os.path.exists (f'{btrootfsmnt}/root/.ssh/authorized_keys'):
263        open (f'{btrootfsmnt}/root/.ssh/authorized_keys', 'w').close()
264    os.chmod (f'{btrootfsmnt}/root/.ssh/authorized_keys', 0o600)
[960b66e]265
266    logger.debug ('importando la clave publica del servidor OG')
[0ab0e61]267    if os.path.exists ('/root/.ssh/id_rsa.pub'):                     ## takes the pubkey from the VM (or docker container) and puts it in the authorized_keys within the chroot
[960b66e]268        fdin = open ('/root/.ssh/id_rsa.pub', 'r')
[c5e9f68]269        fdout = open (f'{btrootfsmnt}/root/.ssh/authorized_keys', 'a')
[960b66e]270        while True:
271            l = fdin.readline()
272            if not l: break
273            fdout.write (l)
274        fdin.close()
275        fdout.close()
276
277    else:
278        logger.error ('no key publica og')
279
[d1822ec]280def ssh_client (btrootfsmnt):
[c5e9f68]281    if not os.path.exists (f'{btrootfsmnt}/root/.ssh/id_rsa'):
[0ab0e61]282        utils.run (['ssh-keygen', '-q', '-f', f'{btrootfsmnt}/root/.ssh/id_rsa', '-N', ''])     ## creates a key pair in the chroot
[960b66e]283
[0ab0e61]284    #cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys          ## takes the pubkey and authorises it to itself
[c5e9f68]285    fdin = open (f'{btrootfsmnt}//root/.ssh/id_rsa.pub', 'r')
286    fdout = open (f'{btrootfsmnt}/root/.ssh/authorized_keys', 'a')
[960b66e]287    while True:
288        l = fdin.readline()
289        if not l: break
290        fdout.write (l)
291    fdin.close()
292    fdout.close()
293
294    ## TODO: exportamos la publica a los repos
295    #cp /root/.ssh/id_rsa.pub /tmp/rsa.ogclient.pub
296
[d1822ec]297def move_initrd (bttargetdir, osrelease):
[960b66e]298    ## backup de oginitrd.img, oginitrd.img.sum, ogvmlinuz y ogvmlinuz.sum
[be59919]299    now = datetime.datetime.now(datetime.timezone.utc).strftime ('%Y%m%d-%H%M%S%z')
[c5e9f68]300    if os.path.exists (f'{bttargetdir}/oginitrd.img'):
301        os.rename (f'{bttargetdir}/oginitrd.img'    , f'{bttargetdir}/oginitrd.img.{now}')
302        os.rename (f'{bttargetdir}/oginitrd.img.sum', f'{bttargetdir}/oginitrd.img.sum.{now}')
303    if os.path.exists (f'{bttargetdir}/ogvmlinuz'):
304        os.rename (f'{bttargetdir}/ogvmlinuz'    , f'{bttargetdir}/ogvmlinuz.{now}')
305        os.rename (f'{bttargetdir}/ogvmlinuz.sum', f'{bttargetdir}/ogvmlinuz.sum.{now}')
[960b66e]306
[c5e9f68]307    shutil.copy (f'/tmp/initrd.img-{osrelease}', f'{bttargetdir}/oginitrd.img')
308    shutil.copy (f'/tmp/vmlinuz-{osrelease}',    f'{bttargetdir}/ogvmlinuz')
[960b66e]309
[95a24ac]310    utils.write_md5 (f'{bttargetdir}/oginitrd.img')
311    utils.write_md5 (f'{bttargetdir}/ogvmlinuz')
[960b66e]312
313    #chmod -R 755 $BTTARGETDIR
[c5e9f68]314    for f in glob.glob (f'{bttargetdir}/oginitrd*') + glob.glob (f'{bttargetdir}/vmlinuz*'):
[be59919]315        os.chmod (f, 0o755)
[bf16103]316
[d1822ec]317def mksquashfs (bttargetdir, btrootfsmnt):
[bf16103]318    logger.info ('Iniciando la creación del sistema de archivos en sqfs')
319
[c5e9f68]320    if os.path.exists (f'{bttargetdir}/ogclient.sqfs'):
[bf16103]321        now = datetime.datetime.now(datetime.timezone.utc).strftime ('%Y%m%d-%H%M%S%z')
[c5e9f68]322        os.rename (f'{bttargetdir}/ogclient.sqfs', f'{bttargetdir}/ogclient.sqfs.{now}')
[bf16103]323
[c79d715]324    ## uses all CPU cores available, even within docker
325    utils.run (['mksquashfs', btrootfsmnt, f'{bttargetdir}/ogclient.sqfs', '-e', 'var/lib/apt/lists', '-e', 'usr/share/doc'])
[c5e9f68]326    os.chmod (f'{bttargetdir}/ogclient.sqfs', 0o744)
[bf16103]327
[95a24ac]328    utils.write_md5 (f'{bttargetdir}/ogclient.sqfs')
[bf16103]329
[d1822ec]330def mkisofs (pxepkg, isolinux_tpl, bttargetdir, nameisoclient):
[bf16103]331    #Preparamos los gestores de arranque
332    try: os.makedirs ('/tmp/iso/isolinux', exist_ok=True)
333    except: raise
334
335    subprocess.run (['cp -a /usr/lib/syslinux/* /tmp/iso/isolinux/'], shell=True)
336
337    if 'gpxe' == pxepkg:
338        subprocess.run (['cp -a /usr/share/gpxe/* /tmp/iso/isolinux'], shell=True)
339    elif 'ipxe' == pxepkg:
340        subprocess.run (['cp -a /usr/lib/ipxe/* /tmp/iso/isolinux'], shell=True)
341    else:
[c5e9f68]342        raise Exception (f'unknown pxepkg value "{pxepkg}"')
[bf16103]343
344    # Si existe el fichero ISO, montarlo para extraer isolinux.bin.
[c5e9f68]345    if os.path.exists (f'/tmp/iso/isolinux/{pxepkg}.iso'):
[bf16103]346        os.mkdir ('/tmp/iso/isolinux/mount')
[95a24ac]347        utils.run (['mount', '-o', 'loop', f'/tmp/iso/isolinux/{pxepkg}.iso', '/tmp/iso/isolinux/mount'])
[bf16103]348        subprocess.run (['cp -a /tmp/iso/isolinux/mount/* /tmp/iso/isolinux'], shell=True)
[95a24ac]349        utils.umount ('/tmp/iso/isolinux/mount')
[bf16103]350        os.rmdir ('/tmp/iso/isolinux/mount')
[c5e9f68]351        os.unlink (f'/tmp/iso/isolinux/{pxepkg}.iso')
[bf16103]352
353    with open ('/tmp/iso/isolinux/isolinux.cfg', 'w') as fd:
354        fd.write (isolinux_tpl.strip().replace('__NAMEISOCLIENT__', nameisoclient).replace('__PXEPKG__', pxepkg))
355
356    # preparamos el directorio boot-tools.
357    if not os.path.exists ('/tmp/iso/ogclient'):
358        os.mkdir ('/tmp/iso/ogclient')
[c5e9f68]359    shutil.copy (f'{bttargetdir}/ogclient.sqfs',     '/tmp/iso/ogclient/')
360    shutil.copy (f'{bttargetdir}/ogclient.sqfs.sum', '/tmp/iso/ogclient/')
361    shutil.copy (f'{bttargetdir}/ogvmlinuz',         '/tmp/iso/ogclient/')
362    shutil.copy (f'{bttargetdir}/ogvmlinuz.sum',     '/tmp/iso/ogclient/')
363    shutil.copy (f'{bttargetdir}/ogvmlinuz',         '/tmp/iso/ogclient/linuxISO')
364    shutil.copy (f'{bttargetdir}/ogvmlinuz.sum',     '/tmp/iso/ogclient/linuxISO.sum')
365    shutil.copy (f'{bttargetdir}/oginitrd.img',      '/tmp/iso/ogclient/')
366    shutil.copy (f'{bttargetdir}/oginitrd.img.sum',  '/tmp/iso/ogclient/')
[bf16103]367    #el ogclienteToISO  debe tener una copia del ogvmlinuz como linuxISO
368    #cp -prv /var/lib/tftpboot/ogclientToIso/* /tmp/iso/ogclient
369
370    oldpwd = os.getcwd()
371    os.chdir ('/tmp')
[fe39c2d]372    logger.debug (f'mkisofs -quiet -V ogClient -o {nameisoclient}.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -J -no-emul-boot -boot-load-size 4 -boot-info-table /tmp/iso')
373    utils.run (['mkisofs', '-quiet', '-V', 'ogClient', '-o', f'{nameisoclient}.iso', '-b', 'isolinux/isolinux.bin', '-c', 'isolinux/boot.cat', '-J', '-no-emul-boot', '-boot-load-size', '4', '-boot-info-table', '/tmp/iso'])
[bf16103]374
[fe39c2d]375    utils.write_md5 (f'{nameisoclient}.iso')
[bf16103]376    os.chdir (oldpwd)
377
[fe39c2d]378    shutil.move (f'/tmp/{nameisoclient}.iso'    , f'/var/lib/tftpboot/ogclient/{nameisoclient}.iso')
379    shutil.move (f'/tmp/{nameisoclient}.iso.sum', f'/var/lib/tftpboot/ogclient/{nameisoclient}.iso.sum')
[305e620]380
381#def __unused_boottoolsBootGraphics():
382#    find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null;
383#    apt-get -y install plymouth plymouth-theme-script
384#    update-alternatives --install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/opengnsys/opengnsys.plymouth 100
385#    update-alternatives --set default.plymouth /lib/plymouth/themes/opengnsys/opengnsys.plymouth
386#    mkdir -p /etc/initramfs-tools/conf.d
387#    echo "FRAMEBUFFER=y" > /etc/initramfs-tools/conf.d/splash
[c2fe8f7]388
389
390############### No usados en el instalador, solo en actualizaciones.
391
392#         ogClientMount [str_program]
393#@brief   Acceso al 2nd FS del cliente desde el Servidor Opengnsys
394#@param 1 Opciona: scripts o programa a ejecutar para automatizaciones
395#@return  Si no hay parametros: login de acceso.
396#@return  con un parametro: La salida del programa ejecutado
397#def ogClientMount():
398#       TODO comprobar que OGFILE y OGFILEMOUNT existe.
399#       mount | grep $OGCLIENTFILE > /dev/null || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256
400#       mount | grep $OGCLIENTMOUNT/proc > /dev/null || mount --bind /proc $OGCLIENTMOUNT/proc
401#       mount | grep $OGCLIENTMOUNT/sys > /dev/null || mount --bind /sys $OGCLIENTMOUNT/sys
402#       mount | grep $OGCLIENTMOUNT/tmp > /dev/null || mount --bind /tmp $OGCLIENTMOUNT/tmp
403#       mount | grep $OGCLIENTMOUNT/dev > /dev/null || mount --bind /dev $OGCLIENTMOUNT/dev
404#       mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null || mount --bind /dev/pts $OGCLIENTMOUNT/dev/pts
405#       [ $# = 0 ] && $(chroot $OGCLIENTMOUNT /sbin/getty 38400 `tty`)
406#       [ $# = 1 ] && chroot $OGCLIENTMOUNT $1
407
408#@brief   Desmonta el 2nd FS del cliente desde el Servidor Opengnsys
409#def ogClientUnmount():
410#       cd /tmp
411#       echo "desmontando cliente espere"
412#       sleep 5
413#       mount | grep $OGCLIENTMOUNT/dev > /dev/null && umount $OGCLIENTMOUNT/dev || ogClientUnmount
414#       mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null && umount $OGCLIENTMOUNT/dev/pts || ogClientUnmount
415#       mount | grep $OGCLIENTMOUNT/proc > /dev/null && umount $OGCLIENTMOUNT/proc || ogClientUnmount
416#       mount | grep $OGCLIENTMOUNT/sys > /dev/null && umount $OGCLIENTMOUNT/sys || ogClientUnmount
417#       mount | grep $OGCLIENTMOUNT/tmp > /dev/null && umount $OGCLIENTMOUNT/tmp || ogClientUnmount
418#       mount | grep $OGCLIENTMOUNT > /dev/null && umount $OGCLIENTMOUNT || ogClientUnmount
Note: See TracBrowser for help on using the repository browser.