source: ogLive-Builder-Git/boottoolsgenerator.py @ c6cf378

browserbuild-browserdeps-vadimfilebeat-installerimprove-versionlgromero-testsmainno-apt-moduleoglive-ipv6pull-from-cloning-enginepybuilder
Last change on this file since c6cf378 was c6cf378, checked in by Natalia Serrano <natalia.serrano@…>, 9 months ago

refs #596 add initial python test

  • Property mode set to 100755
File size: 5.9 KB
Line 
1#!/usr/bin/python3
2
3import sys
4import os
5import logging
6
7sys.path.insert (0, __file__)
8from boottoolsfunctions import btogGetOsInfo1, btogGetOsInfo2, btogGetVar
9
10logging.basicConfig (filename='/tmp/boot-tools_installation.log', filemode='a', format='%(levelname)s %(asctime)s (%(threadName)s) (%(funcName)s) %(message)s', level=logging.INFO)
11logger = logging.getLogger ('boottools')
12
13#BRANCH = 'branches/master'
14#svn export --force https://github.com/opengnsys/OpenGnsys/$BRANCH/client /tmp/opengnsys_installer/opengnsys/client
15
16type_client    = sys.argv[1] if len(sys.argv)>1 else 'host'
17#WORKDIR        = '/tmp/opengnsys_installer'
18#INSTALL_TARGET = '/opt/opengnsys'
19#PROGRAMDIR     = $(readlink -e $(dirname "$0"))
20
21if os.getuid():
22    logger.error ('ERROR: this program must run under root privileges!!')
23    os._exit (1)
24
25os.chdir ('/tmp')
26
27#for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
28#for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
29#for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
30
31
32
33####################################################################3
34logger.info ('FASE 1 - Asignación de variables')
35ogclientcfg, osdistrib, oscodename, osrelease, osarch, oshttp = btogGetOsInfo1(type_client)
36print (osarch)
37btdir, bttargetdir, btrootfsimg, btrootfsmnt, btrootfsimglabel, log_file, versionboottools, btvirtualdisksize = btogGetVar(osarch)
38print (btdir)
39gitrelease, nameisoclient, namehostclient = btogGetOsInfo2(type_client, versionboottools, ogclientcfg, osdistrib, oscodename, osrelease, osarch, oshttp)
40print (nameisoclient)
41logger.info ('OpenGnsys CLIENT installation begins')
42
43
44##########################################################################
45logger.info ('FASE 2 - Instalación de software adicional.')
46"""
47#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
48apt-get update >>/tmp/fase2.out
49[ -n "$(apt-cache search gpxe)" ] && PXEPKG="gpxe"
50[ -n "$(apt-cache search ipxe)" ] && PXEPKG="ipxe"
51apt-get -y install debootstrap subversion schroot squashfs-tools syslinux genisoimage $PXEPKG qemu qemu-utils lsof >>/tmp/fase2.out
52
53
54###################################################################3
55logger.info ('FASE 3 - Creación del Sistema raiz RootFS (Segundo Sistema archivos (img))')
56logger.info ('Fase 3.1 Generar y formatear el disco virtual. Generar el dispositivo loop.')
57file $BTROOTFSIMG | grep "partition 1: ID=0x83"
58if [ $? == 1 ]:
59        btogSetFsVirtual || exit 2
60    echo ================= nati after btogSetFsVirtual; ls -la /opt/opengnsys/tftpboot/ogclient/
61
62logger.info ('Fase 3.2 Generar sistema de archivos con debootstrap')
63schroot -p -c IMGogclient -- touch /tmp/ogclientOK
64if [ -f /tmp/ogclientOK ]
65then
66        rm /tmp/ogclientOK
67else
68        btogSetFsBase >>/tmp/fase3.out
69fi
70echo ================= nati after fase 3; ls -la /opt/opengnsys/tftpboot/ogclient/
71
72
73###################################################################3
74logger.info ('FASE 4 - Configurar acceso schroot al Segundo Sistema de archivos (img)')
75cat /etc/schroot/schroot.conf | grep $BTROOTFSIMG || btogSetFsAccess
76
77
78###########################################################################
79logger.info ('FASE 5 - Incorporando ficheros OpenGnsys al sistema raíz rootfs')
80cp -a ${BTDIR}/includes/usr/bin/* /tmp >>/tmp/fase5.out
81chmod +x /tmp/boot-tools/*.sh
82# Incluir revisión.
83sed -i "1 s/$/ $GITRELEASE ($OSRELEASE)/" ${BTDIR}/includes/etc/initramfs-tools/scripts/VERSION.txt
84# En Ubuntu 13.04+ es necesario matar proceso de "udev" antes de desmontar.
85umount $BTROOTFSMNT 2>/dev/null || (kill -9 $(lsof -t $BTROOTFSMNT); umount $BTROOTFSMNT) 2>/dev/null
86schroot -p -c IMGogclient -- /tmp/boot-tools/boottoolsFsOpengnsys.sh >>/tmp/fase5.out
87
88
89############################################################################################
90logger.info ('FASE 6 - Instalar software')
91logger.info ('Fase 6.1 instalar paquetes deb con apt-get')
92schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareInstall.sh >>/tmp/fase6.out
93logger.info ('Fase 6.2 compilar software.')
94cd /
95schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareCompile.sh >>/tmp/fase6.out
96cd -
97
98
99############################################################################################
100logger.info ('FASE 7 - Personalizar el sistema creado')
101logger.info ('Fase 7.1 Incorporar la clave publica del servidor')
102cd /
103ssh-keygen -q -f /root/.ssh/id_rsa -N ""
104cp /root/.ssh/id_rsa.pub /tmp
105schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshServer.sh
106cd -
107logger.info ('Fase 7.2. Incorpoar la clave publica del propio  cliente')
108schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshClient.sh
109
110logger.info ('Fase 7.3. Configurando las locales')
111schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsFsLocales.sh
112
113for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
114for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
115for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
116
117echo ================= nati after fase 7; ls -la /opt/opengnsys/tftpboot/ogclient/
118
119
120#########################################################################
121logger.info ('FASE 8 - Generar distribucion')
122logger.info ('Fase 8.1 Generar el initrd')
123btogFsInitrd >>/tmp/fase8.out
124echo ================= nati after fase 8.1; ls -la /opt/opengnsys/tftpboot/ogclient/
125logger.info ('Fase 8.2 Generar fichero sqfs a partir del fichero img')
126btogFsSqfs
127echo ================= nati after fase 8.2; ls -la /opt/opengnsys/tftpboot/ogclient/
128umount $BTROOTFSMNT 2>/dev/null
129logger.info ('Fase 8.3 Generar la ISO')
130btogIsoGenerator >>/tmp/fase8.out
131echo ================= nati after fase 8.3; ls -la /opt/opengnsys/tftpboot/ogclient/
132
133echoAndLog "OpenGnsys installation finished at $(date)"
134"""
Note: See TracBrowser for help on using the repository browser.