refs #596 reorganise configuration, refactor md5 hashing, move installation files
parent
0371870fa0
commit
ef212bc84e
|
@ -7,12 +7,12 @@ import shutil
|
|||
import argparse
|
||||
|
||||
#VERSIONBOOTTOOLS="ogLive"
|
||||
nameisoclientfile = '/tmp/opengnsys_info_rootfs'
|
||||
namehostclientfile = '/tmp/opengnsys_chroot'
|
||||
#nameisoclientfile = '/tmp/opengnsys_info_rootfs'
|
||||
#namehostclientfile = '/tmp/opengnsys_chroot'
|
||||
|
||||
svnclientdir = '/tmp/opengnsys_installer/opengnsys/client/boot-tools'
|
||||
svnclientstructure = '/tmp/opengnsys_installer/opengnsys/client/shared'
|
||||
svnclientengine = '/tmp/opengnsys_installer/opengnsys/client/engine'
|
||||
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]))
|
||||
|
|
|
@ -5,12 +5,11 @@ import os
|
|||
import sys
|
||||
import re
|
||||
import subprocess
|
||||
import configparser
|
||||
|
||||
from boottoolsfunctions import _run, _read_config
|
||||
|
||||
config = _read_config ('boottoolsgenerator.cfg')
|
||||
debconf_settings = config['debconf'].get ('settings')
|
||||
debconf_settings = config['General'].get ('debconf_settings')
|
||||
|
||||
def _aptget_clean():
|
||||
_run (['apt-get', '--yes', 'clean'])
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
import os
|
||||
import subprocess
|
||||
import configparser
|
||||
from boottoolsfunctions import _run, _read_config
|
||||
|
||||
config = _read_config ('boottoolsgenerator.cfg')
|
||||
debconf_settings2 = config['debconf'].get ('settings2')
|
||||
debconf_settings2 = config['General'].get ('debconf_settings2')
|
||||
|
||||
subprocess.run (['debconf-set-selections'], input=debconf_settings2, text=True)
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import subprocess
|
|||
import shutil
|
||||
import glob
|
||||
import datetime
|
||||
import configparser
|
||||
|
||||
logger = logging.getLogger ('boottools')
|
||||
|
||||
|
@ -51,8 +52,14 @@ def _read_config (fn):
|
|||
config.read (fn)
|
||||
return config
|
||||
|
||||
def _write_md5 (fn):
|
||||
md5, _ = _run (['md5sum', fn])
|
||||
md5, rest = md5.split (' ', 1)
|
||||
with open (f'{fn}.sum', 'w') as fd:
|
||||
fd.write (md5 + '\n')
|
||||
|
||||
def btogGetVar (osarch):
|
||||
btdir = '/tmp/opengnsys_installer/opengnsys/client/boot-tools'
|
||||
btdir = '/tmp/opengnsys/oglive_builder'
|
||||
bttargetdir = '/var/lib/tftpboot/ogclient/'
|
||||
btrootfsimg = os.path.join (bttargetdir, 'ogclient.img')
|
||||
btrootfsmnt = os.path.join (bttargetdir, 'ogclientmount')
|
||||
|
@ -380,19 +387,8 @@ def btogFsInitrd (bttargetdir, osrelease):
|
|||
shutil.copy (f'/tmp/initrd.img-{osrelease}', f'{bttargetdir}/oginitrd.img')
|
||||
shutil.copy (f'/tmp/vmlinuz-{osrelease}', f'{bttargetdir}/ogvmlinuz')
|
||||
|
||||
#DATASUM=`md5sum "${BTTARGETDIR}/oginitrd.img" | cut -f1 -d" "`
|
||||
md5, _ = _run (['md5sum', f'{bttargetdir}/oginitrd.img'])
|
||||
md5, rest = md5.split (' ', 1)
|
||||
#echo $DATASUM > ${BTTARGETDIR}/oginitrd.img.sum
|
||||
with open (f'{bttargetdir}/oginitrd.img.sum', 'w') as fd:
|
||||
fd.write (md5)
|
||||
|
||||
#DATASUM=`md5sum "${BTTARGETDIR}/ogvmlinuz" | cut -f1 -d" "`
|
||||
md5, _ = _run (['md5sum', f'{bttargetdir}/ogvmlinuz'])
|
||||
md5, rest = md5.split (' ', 1)
|
||||
#echo $DATASUM > ${BTTARGETDIR}/ogvmlinuz.sum
|
||||
with open (f'{bttargetdir}/ogvmlinuz.sum', 'w') as fd:
|
||||
fd.write (md5)
|
||||
_write_md5 (f'{bttargetdir}/oginitrd.img')
|
||||
_write_md5 (f'{bttargetdir}/ogvmlinuz')
|
||||
|
||||
#cd -
|
||||
#chmod -R 755 $BTTARGETDIR
|
||||
|
@ -411,12 +407,7 @@ def btogFsSqfs (bttargetdir, btrootfsmnt):
|
|||
_run (['mksquashfs', btrootfsmnt, f'{bttargetdir}/ogclient.sqfs'])
|
||||
os.chmod (f'{bttargetdir}/ogclient.sqfs', 0o744)
|
||||
|
||||
#DATASUM=`md5sum "${BTTARGETDIR}/ogclient.sqfs" | cut -f1 -d" "`
|
||||
md5, _ = _run (['md5sum', f'{bttargetdir}/ogclient.sqfs'])
|
||||
md5, rest = md5.split (' ', 1)
|
||||
#echo $DATASUM > ${BTTARGETDIR}/ogclient.sqfs.sum
|
||||
with open (f'{bttargetdir}/ogclient.sqfs.sum', 'w') as fd:
|
||||
fd.write (md5)
|
||||
_write_md5 (f'{bttargetdir}/ogclient.sqfs')
|
||||
|
||||
# btogIsoGenerator genera la iso del cliente
|
||||
def btogIsoGenerator (pxepkg, isolinux_tpl, bttargetdir, nameisoclient):
|
||||
|
@ -465,13 +456,7 @@ def btogIsoGenerator (pxepkg, isolinux_tpl, bttargetdir, nameisoclient):
|
|||
logger.debug (f'mkisofs -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')
|
||||
_run (['mkisofs', '-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'])
|
||||
|
||||
##Generamos el md5
|
||||
#DATASUM=`md5sum ${NAMEISOCLIENT}.iso | cut -f1 -d" "`
|
||||
md5, _ = _run (['md5sum', f'{nameisoclient}.iso'])
|
||||
md5, rest = md5.split (' ', 1)
|
||||
#echo $DATASUM > ${NAMEISOCLIENT}.iso.sum
|
||||
with open (f'{nameisoclient}.iso.sum', 'w') as fd:
|
||||
fd.write (md5)
|
||||
_write_md5 (f'{nameisoclient}.iso')
|
||||
os.chdir (oldpwd)
|
||||
|
||||
os.rename (f'/tmp/{nameisoclient}.iso' , f'/var/lib/tftpboot/ogclient/{nameisoclient}.iso')
|
||||
|
|
|
@ -66,22 +66,18 @@ xwindows =
|
|||
|
||||
logging_level = INFO
|
||||
|
||||
[debconf]
|
||||
|
||||
settings =
|
||||
debconf_settings =
|
||||
kexec-tools kexec-tools/load_kexec boolean true
|
||||
openssh-server openssh-server/permit-root-login boolean true
|
||||
refind refind/install_to_esp boolean false
|
||||
|
||||
settings2 =
|
||||
debconf_settings2 =
|
||||
console-setup console-setup/charmap47 select UTF-8
|
||||
console-setup console-setup/codeset47 select . Combined - Latin; Slavic Cyrillic; Greek
|
||||
console-setup console-setup/fontface47 select VGA
|
||||
console-setup console-setup/fontsize-fb47 select 8x16
|
||||
|
||||
[ISOLinux]
|
||||
|
||||
template =
|
||||
isolinux_template =
|
||||
DEFAULT menu.c32
|
||||
PROMPT 0
|
||||
ALLOWOPTIONS 1
|
||||
|
|
|
@ -6,7 +6,6 @@ import logging
|
|||
import subprocess
|
||||
import glob
|
||||
import stat
|
||||
import configparser
|
||||
import shutil
|
||||
|
||||
curdir = os.path.dirname (__file__)
|
||||
|
@ -14,7 +13,7 @@ sys.path.insert (0, curdir)
|
|||
from boottoolsfunctions import _run, _mount, _umount, _read_config, btogGetOsInfo1, btogGetOsInfo2, btogGetVar, btogSetFsVirtual, btogSetFsAccess, btogSetFsBase, boottoolsSshServer, boottoolsSshClient, btogFsInitrd, btogFsSqfs, btogIsoGenerator
|
||||
|
||||
config = _read_config ('boottoolsgenerator.cfg')
|
||||
isolinux_tpl = config['ISOLinux'].get ('template')
|
||||
isolinux_tpl = config['General'].get ('isolinux_template')
|
||||
lvl = config['General'].get ('logging_level')
|
||||
|
||||
numeric_level = getattr (logging, lvl.upper(), None)
|
||||
|
@ -35,12 +34,12 @@ def _logging():
|
|||
logger = _logging()
|
||||
|
||||
def clone_client_dirs():
|
||||
if not os.path.exists ('/tmp/opengnsys_installer/opengnsys/client/engine'):
|
||||
if not os.path.exists ('/tmp/opengnsys/engine'):
|
||||
branch = 'main'
|
||||
tmpdir, _ = _run (['mktemp', '--tmpdir', '--directory', 'oggit.XXXXXX'])
|
||||
logger.debug (f'tmpdir "{tmpdir}"')
|
||||
_run (['git', 'clone', '-c', 'http.sslVerify=false', '--branch', branch, 'https://ognproject.evlt.uma.es/gitea/opengnsys/opengnsys.git', tmpdir])
|
||||
_run (['rsync', '-aH', f'{tmpdir}/client/engine', f'{tmpdir}/client/shared', '/tmp/opengnsys_installer/opengnsys/client/'])
|
||||
_run (['rsync', '-aH', f'{tmpdir}/client/engine', f'{tmpdir}/client/shared', '/tmp/opengnsys/'])
|
||||
_run (['rm', '-rf', tmpdir])
|
||||
|
||||
type_client = sys.argv[1] if len(sys.argv)>1 else 'host'
|
||||
|
|
Loading…
Reference in New Issue