Translate the ogLive builder to python #1
|
@ -0,0 +1,12 @@
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.dockerignore
|
||||||
|
__pycache__
|
||||||
|
Dockerfile
|
||||||
|
INSTALL.es.txt
|
||||||
|
Jenkinsfile
|
||||||
|
kernelParameterOG.es.txt
|
||||||
|
ogclient/
|
||||||
|
ogclientImg2Sqfs
|
||||||
|
ogclientSqfs2Img
|
||||||
|
**/*.swp
|
|
@ -0,0 +1,2 @@
|
||||||
|
__pycache__/
|
||||||
|
*.swp
|
|
@ -0,0 +1,40 @@
|
||||||
|
FROM ubuntu:noble
|
||||||
|
|
||||||
|
ARG OPENGNSYS_BRANCH=main
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get -y install \
|
||||||
|
debootstrap \
|
||||||
|
fdisk \
|
||||||
|
file \
|
||||||
|
genisoimage \
|
||||||
|
git \
|
||||||
|
ipxe \
|
||||||
|
jq \
|
||||||
|
lsof \
|
||||||
|
python3 \
|
||||||
|
python3-apt \
|
||||||
|
qemu-utils \
|
||||||
|
rsync \
|
||||||
|
schroot \
|
||||||
|
squashfs-tools \
|
||||||
|
subversion \
|
||||||
|
syslinux \
|
||||||
|
syslinux-efi \
|
||||||
|
syslinux-utils \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN groupadd opengnsys
|
||||||
|
RUN mkdir -p /opt/opengnsys/client /tmp/opengnsys/oglive_builder /var/lib/tftpboot/
|
||||||
|
RUN ln -fs /var/lib/tftpboot /opt/opengnsys
|
||||||
|
|
||||||
|
## take stuff from the OG repo: a) cloning engine, b) shared stuff and c) gitrelease
|
||||||
|
RUN git clone -c http.sslVerify=false --branch ${OPENGNSYS_BRANCH} https://ognproject.evlt.uma.es/gitea/opengnsys/opengnsys.git /tmp/ogrepo && \
|
||||||
|
mv /tmp/ogrepo/client/engine /tmp/ogrepo/client/shared /tmp/opengnsys/ && \
|
||||||
|
git --git-dir /tmp/ogrepo/.git log --date format:r%Y%m%d --format=%ad -1 >/tmp/opengnsys/oglive_builder/gitrelease && \
|
||||||
|
rm -rf /tmp/ogrepo/
|
||||||
|
|
||||||
|
#RUN echo 0 ## development: invalidate docker cache at this point, so that the 'COPY' below actually copies files
|
||||||
|
COPY . /tmp/opengnsys/oglive_builder/
|
||||||
|
RUN cp /tmp/opengnsys/oglive_builder/schroot.conf /tmp/opengnsys/oglive_builder/mount-defaults /etc/schroot/ && echo '' >/etc/schroot/default/nssdatabases && rm -f /etc/schroot/setup.d/*chrootname
|
||||||
|
|
||||||
|
ENTRYPOINT ["/tmp/opengnsys/oglive_builder/mkoglive.py"]
|
|
@ -4,58 +4,66 @@ OpenGnsys Client boot-tools INSTALL.es.txt
|
||||||
|
|
||||||
Advertencia previa:
|
Advertencia previa:
|
||||||
-----------------------------
|
-----------------------------
|
||||||
- No usar este instalador en un sistema OpenGnsys en producción.
|
|
||||||
- Se puede ejecutar este script desde un sistema Ubuntu 10.04 o superior.
|
- Se puede ejecutar este script desde un sistema Ubuntu 10.04 o superior.
|
||||||
- Mas información https://opengnsys.es/trac/wiki/ClienteInitrdDSGenerarloV1.0.2
|
- Mas información https://opengnsys.es/trac/wiki/ClienteInitrdDSGenerarloV1.0.2
|
||||||
|
|
||||||
|
|
||||||
Requisitos iniciales
|
Requisitos iniciales
|
||||||
--------------------
|
--------------------
|
||||||
- Utilizar el usuario "root" para ejecutar el proceso de generación del cliente.
|
|
||||||
- Comprobar la conexión a Internet, sobre todo si usas proxy (el hecho de que funcione apt-get no significa que tengas el proxy configurado).
|
- Comprobar la conexión a Internet, sobre todo si usas proxy (el hecho de que funcione apt-get no significa que tengas el proxy configurado).
|
||||||
|
|
||||||
|
|
||||||
Proceso de instalación
|
Proceso de creación de imagen docker
|
||||||
----------------------
|
------------------------------------
|
||||||
|
|
||||||
#0. Si ya tenemos configurado TFTP, renombrar el directorio /var/lib/tftpboot/ogclient.
|
Simplemente llamar a docker build sin sorpresas:
|
||||||
mv /opt/opengnsys/tftpboot/ogclient /opt/opengnsys/tftpboot/ogclient-old;
|
|
||||||
|
|
||||||
#1. Descargar del Subversion las herramientas del cliente
|
docker build -t opengnsys/mkoglive .
|
||||||
apt-get install subversion wget
|
|
||||||
svn checkout https://opengnsys.es/svn/branches/version1.1/client /tmp/opengnsys_installer/opengnsys/client/;
|
|
||||||
find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null;
|
|
||||||
|
|
||||||
#2. Ejecutar el instalador:
|
Si queremos usar una rama diferente del repo de opengnsys:
|
||||||
/tmp/opengnsys_installer/opengnsys/client/boot-tools/boottoolsgenerator.sh;
|
|
||||||
|
|
||||||
Notas para ejecución del instalador en Ubuntu 12.10:
|
docker build --build-arg OPENGNSYS_BRANCH=mybranch -t opengnsys/mkoglive .
|
||||||
- Configuración openssh-client:
|
|
||||||
- *** ssh_config (Y/I/N/O/D/Z) [default=N] ? [intro]
|
|
||||||
- Mapa de caracteres:
|
|
||||||
- Pantalla "Configuring console-data": elegir "Select keymap from full list"
|
|
||||||
- Keymap: pc / qwerty / Spanish / Standard / Standard
|
|
||||||
- Clave publica del servidor
|
|
||||||
- verwrite (y/n)? [intro]
|
|
||||||
- Mapa de caracteres (repetición):
|
|
||||||
- Pantalla "Configuring console-data":
|
|
||||||
- Select keymap from full list
|
|
||||||
- pc / qwerty / Spanish / Standard / Standard, UTF-8, Combined - Latin; Slavic Cyrillic; Greek, Fixed, 16
|
|
||||||
|
|
||||||
|
|
||||||
|
Proceso de creación de imagen oglive
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
mkdir ogclient
|
||||||
|
docker run --rm --name mkoglive --privileged=true --volume $PWD/ogclient:/var/lib/tftpboot/ogclient opengnsys/mkoglive --codename noble
|
||||||
|
|
||||||
|
Hace falta --privileged=true para que mkoglive.py pueda ejecutar, entre otras cosas, losetup y mount.
|
||||||
|
|
||||||
|
El parámetro --codename permite especificar la versión de ubuntu.
|
||||||
|
|
||||||
|
También se puede especificar, por ejemplo, --loglevel debug.
|
||||||
|
|
||||||
|
Y también podemos indicar otro archivo de configuración usando --config.
|
||||||
|
|
||||||
|
Las imágenes se crean en ./ogclient. Es conveniente crear este directorio con antelación, antes de ejecutar docker, porque de este modo el directorio queda con permisos de usuario. De lo contrario, docker lo crearía como root y necesitaríamos sudo para hacer cualquier cosa dentro de él.
|
||||||
|
|
||||||
|
Puede que durante la ejecución del contenedor salga un error como este una o más veces:
|
||||||
|
|
||||||
|
Exception ignored in: <function _acquireLock at 0x7fdac10f1f80>
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "/usr/lib/python3.12/logging/__init__.py", line 241, in _acquireLock
|
||||||
|
_lock.acquire()
|
||||||
|
|
||||||
|
Es un bug conocido en la biblioteca "logging" de python, para el cual ya existe solución y solo es cuestión de tiempo que la versión de python incluida en ubuntu incluya el fix.
|
||||||
|
|
||||||
|
|
||||||
Descripción de la estrucutra de boot-tools
|
Descripción de la estrucutra de boot-tools
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
- INSTALL.es.txt este mismo archivo.
|
- INSTALL.es.txt este mismo archivo.
|
||||||
- boottollsgenerator.sh proceso de generación del sistema operativo opengnsys.
|
- mkoglive:
|
||||||
- boottoolsfunctions.lib libreria complementaria del boottolsgenerator.sh
|
- mkoglive.py script principal para crear la imagen oglive
|
||||||
- includes/ directorio con ficheros específicos para incluir en la distribución.
|
- mkoglive.cfg configuración de mkoglive.py
|
||||||
|
- boottools/ libreria complementaria del mkoglive.py
|
||||||
|
- includes/ directorio con ficheros específicos para incluir en la distribución
|
||||||
|
- schroot:
|
||||||
NOTA:
|
- schroot.conf configuración de schroot
|
||||||
boottollsfuncions.lib -> btogSetfsBase
|
- mount-defaults configuración de puntos de montaje para schroot
|
||||||
bootsoftwareinstall ->
|
- chroot-tasks.py helper para configurar el oglive estando en schroot
|
||||||
packages ->sw.testing
|
- docker:
|
||||||
|
- Dockerfile para crear una imagen docker
|
||||||
|
- .dockerignore para limitar el contexto de docker-build
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import apt
|
||||||
|
import apt.progress.base
|
||||||
|
import apt_pkg
|
||||||
|
import shutil
|
||||||
|
import os
|
||||||
|
|
||||||
|
def clean():
|
||||||
|
apt_cache = apt.Cache()
|
||||||
|
|
||||||
|
apt_pkg.init()
|
||||||
|
cache_dir = apt_pkg.config.find_dir ('Dir::Cache::archives')
|
||||||
|
|
||||||
|
for fn in os.listdir (cache_dir):
|
||||||
|
file_path = os.path.join (cache_dir, fn)
|
||||||
|
try:
|
||||||
|
if os.path.isfile (file_path):
|
||||||
|
os.unlink (file_path)
|
||||||
|
elif os.path.isdir (file_path):
|
||||||
|
shutil.rmtree (file_path)
|
||||||
|
except Exception as e:
|
||||||
|
print (f'Failed to delete {file_path}. Reason: {e}')
|
||||||
|
|
||||||
|
def autoremove():
|
||||||
|
apt_cache = apt.Cache()
|
||||||
|
for pkg in apt_cache:
|
||||||
|
if pkg.is_installed and pkg.is_auto_removable:
|
||||||
|
pkg.mark_delete()
|
||||||
|
try:
|
||||||
|
apt_cache.commit()
|
||||||
|
except Exception as e:
|
||||||
|
print ('installation failed: {}'.format (str (e)))
|
||||||
|
|
||||||
|
def remove (pkgs):
|
||||||
|
apt_cache = apt.Cache()
|
||||||
|
for p in pkgs:
|
||||||
|
if p in apt_cache:
|
||||||
|
apt_cache[p].mark_delete()
|
||||||
|
try:
|
||||||
|
apt_cache.commit()
|
||||||
|
except Exception as e:
|
||||||
|
print ('removal failed: {}'.format (str (e)))
|
||||||
|
|
||||||
|
def update():
|
||||||
|
apt_cache = apt.Cache()
|
||||||
|
apt_cache.update()
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
apt_cache = apt.Cache()
|
||||||
|
apt_cache.upgrade()
|
||||||
|
|
||||||
|
def cache_search (pkgs):
|
||||||
|
apt_cache = apt.Cache()
|
||||||
|
res = {}
|
||||||
|
for p in pkgs:
|
||||||
|
res[p] = True if p in apt_cache else False
|
||||||
|
return res
|
||||||
|
|
||||||
|
def install (pkgs, opts={}):
|
||||||
|
apt_pkg.init()
|
||||||
|
|
||||||
|
if opts:
|
||||||
|
apt_pkg.init_config()
|
||||||
|
for k in opts:
|
||||||
|
apt_pkg.config.set (k, opts[k])
|
||||||
|
|
||||||
|
cache = apt_pkg.Cache()
|
||||||
|
sl = apt_pkg.SourceList()
|
||||||
|
sl.read_main_list()
|
||||||
|
cache.update (apt.progress.base.AcquireProgress(), sl)
|
||||||
|
|
||||||
|
_to_install = []
|
||||||
|
dep_cache = apt_pkg.DepCache(cache)
|
||||||
|
for p in pkgs:
|
||||||
|
package = cache[p]
|
||||||
|
if not package:
|
||||||
|
print (f'package "{p}" not found')
|
||||||
|
continue
|
||||||
|
_to_install.append (p)
|
||||||
|
dep_cache.mark_install(package)
|
||||||
|
|
||||||
|
if _to_install:
|
||||||
|
print ('about to install these packages: "{}"'.format (' '.join (_to_install)))
|
||||||
|
fetcher = apt_pkg.Acquire()
|
||||||
|
install_progress = apt.progress.base.InstallProgress()
|
||||||
|
dep_cache.commit(fetcher, install_progress)
|
|
@ -0,0 +1,413 @@
|
||||||
|
import platform
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
import subprocess
|
||||||
|
import shutil
|
||||||
|
import glob
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
|
logger = logging.getLogger ('boottools')
|
||||||
|
|
||||||
|
def GetVar (osarch):
|
||||||
|
bttargetdir = '/var/lib/tftpboot/ogclient/'
|
||||||
|
btrootfsimg = os.path.join (bttargetdir, 'ogclient.img')
|
||||||
|
btrootfsmnt = os.path.join (bttargetdir, 'ogclientmount')
|
||||||
|
if 'i386' == osarch:
|
||||||
|
btvirtualdisksize = '2000' # tamaño maximo limitado por schroot 2GB para 32 bits
|
||||||
|
else:
|
||||||
|
btvirtualdisksize = '3G'
|
||||||
|
return bttargetdir, btrootfsimg, btrootfsmnt, btvirtualdisksize
|
||||||
|
|
||||||
|
def GetOsInfo (type_client='host'):
|
||||||
|
if 'precise' == type_client: # ogLive 1.0.4-rc2 basado en Ubuntu 12.04 LTS.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='precise'
|
||||||
|
osrelease='3.2.0-23-generic'
|
||||||
|
osarch='i386'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'wheezy' == type_client: # ogLive basado en Debian 7.3.
|
||||||
|
osdistrib='debian'
|
||||||
|
oscodename='wheezy'
|
||||||
|
osrelease='3.2.0-4-i386'
|
||||||
|
osarch='i386'
|
||||||
|
oshttp='http://ftp.es.debian.org/debian/'
|
||||||
|
elif 'quantal' == type_client: # ogLive 1.0.5-rc2 basado en Ubuntu 12.10 con Kernel descargado.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='quantal'
|
||||||
|
osrelease='3.7.6-030706-generic'
|
||||||
|
osarch='i386'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'raring' == type_client: # ogLive 1.0.5-rc3 basado en Ubuntu 13.04.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='raring'
|
||||||
|
osrelease='3.8.0-22-generic'
|
||||||
|
osarch='i386'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'trusty' == type_client: # ogLive 1.0.5-rc4 basado en Ubuntu 14.04.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='trusty'
|
||||||
|
osrelease='3.13.0-24-generic'
|
||||||
|
osarch='i386'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'vivid' == type_client: # ogLive 1.1.0-rc2 basado en Ubuntu 15.04.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='vivid'
|
||||||
|
osrelease='3.19.0-49-generic'
|
||||||
|
osarch='i386'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'wily' == type_client: # ogLive 1.1.0-rc1 basado en Ubuntu 15.10.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='wily'
|
||||||
|
osrelease='4.2.0-35-generic'
|
||||||
|
osarch='i386'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'xenial' == type_client or 'xenial-4.4' == type_client: # ogLive 1.1.0-rc4 basado en Ubuntu 16.04 y Kernel 4.4.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='xenial'
|
||||||
|
osrelease='4.4.0-34-generic'
|
||||||
|
osarch='i386'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'xenial-4.8' == type_client: # ogLive 1.1.0-rc5 basado en Ubuntu 16.04 y Kernel 4.8.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='xenial'
|
||||||
|
osrelease='4.8.0-39-generic'
|
||||||
|
osarch='amd64'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'xenial-4.13' == type_client: # ogLive 1.1.0-rc6 basado en Ubuntu 16.04 y Kernel 4.13.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='xenial'
|
||||||
|
osrelease='4.13.0-17-generic'
|
||||||
|
osarch='amd64'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'bionic' == type_client or 'bionic-4.15' == type_client: # ogLive 1.1.1-rc1 basado en Ubuntu 18.04 y Kernel 4.15.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='bionic'
|
||||||
|
osrelease='4.15.0-32-generic'
|
||||||
|
osarch='amd64'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'bionic-4.18' == type_client: # ogLive 1.1.1-rc3 basado en Ubuntu 18.04 y Kernel 4.18.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='bionic'
|
||||||
|
osrelease='4.18.0-20-generic'
|
||||||
|
osarch='amd64'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'bionic-5.0' == type_client: # ogLive 1.1.1-rc5 basado en Ubuntu 18.04 y Kernel 5.0.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='bionic'
|
||||||
|
osrelease='5.0.0-27-generic'
|
||||||
|
osarch='amd64'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'focal' == type_client: # ogLive 1.2.0-rc1 basado en Ubuntu 20.04 y Kernel 5.4.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='focal'
|
||||||
|
osrelease='5.4.0-42-generic'
|
||||||
|
osarch='amd64'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'noble' == type_client: # ogLive 1.2.0-rc1 basado en Ubuntu 24.04 y Kernel 6.8.
|
||||||
|
osdistrib='ubuntu'
|
||||||
|
oscodename='noble'
|
||||||
|
osrelease='6.8.0-31-generic'
|
||||||
|
osarch='amd64'
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
elif 'host' == type_client: # ogLive basado en la distribución del servidor.
|
||||||
|
osdistrib=platform.freedesktop_os_release()['NAME']
|
||||||
|
oscodename=platform.freedesktop_os_release()['VERSION_CODENAME']
|
||||||
|
osrelease=platform.uname()[2]
|
||||||
|
osarch, _=utils.run (['dpkg', '--print-architecture'])
|
||||||
|
oshttp='http://es.archive.ubuntu.com/ubuntu/'
|
||||||
|
else: # Parámetro desconocido
|
||||||
|
logger.error ('Parámetro no válido.')
|
||||||
|
osdistrib=None
|
||||||
|
oscodename=None
|
||||||
|
osrelease=None
|
||||||
|
osarch=None
|
||||||
|
oshttp=None
|
||||||
|
return osdistrib, oscodename, osrelease, osarch, oshttp
|
||||||
|
|
||||||
|
def mkrootfs (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize, bttargetdir, osarch):
|
||||||
|
logger.info (f'Creación y formateo del disco virtual "{btrootfsimg}" "{btvirtualdisksize}" MB')
|
||||||
|
|
||||||
|
try: utils.umount (btrootfsmnt)
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
if (utils.is_mounted (btrootfsmnt)):
|
||||||
|
raise Exception (f'failed to umount "{btrootfsmnt}"')
|
||||||
|
|
||||||
|
try: os.makedirs (btrootfsmnt, exist_ok=True)
|
||||||
|
except:
|
||||||
|
raise Exception (f'Creando directorio "{btrootfsmnt}" : ERROR')
|
||||||
|
|
||||||
|
try: utils.run (['chown', '-R', 'root:opengnsys', bttargetdir])
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception (f'Failed to chown root:opengnsys "{btrootfsmnt}": {str(e)}')
|
||||||
|
|
||||||
|
logger.info (f'Creating disk image "{btrootfsimg}"')
|
||||||
|
if 'i386' == osarch:
|
||||||
|
try: utils.run (['dd', 'if=/dev/zero', f'of={btrootfsimg}', 'bs=1048576', f'count={btvirtualdisksize}'])
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception (f'Creando el disco virtual "{btrootfsimg}" con tamaño maxima "{btvirtualdisksize}" MB : ERROR: {str(e)}')
|
||||||
|
else:
|
||||||
|
try: utils.run (['qemu-img', 'create', btrootfsimg, btvirtualdisksize])
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception (f'Creando el disco virtual "{btrootfsimg}" con tamaño maxima "{btvirtualdisksize}" MB : ERROR: {str(e)}')
|
||||||
|
|
||||||
|
logger.debug ('losetup --find')
|
||||||
|
diskloop, _ = utils.run (['losetup', '--find'])
|
||||||
|
if not diskloop:
|
||||||
|
raise Exception ('no diskloop')
|
||||||
|
|
||||||
|
logger.debug ('losetup attach')
|
||||||
|
try: utils.run (['losetup', '--partscan', diskloop, btrootfsimg])
|
||||||
|
except: raise Exception ('losetup failed')
|
||||||
|
|
||||||
|
logger.info ('Partitioning disk image')
|
||||||
|
stdout, _ = utils.run (['bash', '-c', f"echo $'n\np\n1\n\n\nt\n83\nw' |fdisk {diskloop}"])
|
||||||
|
|
||||||
|
time.sleep (3)
|
||||||
|
logger.debug ('losetup --detach')
|
||||||
|
try: utils.run (['losetup', '--detach', diskloop])
|
||||||
|
except:
|
||||||
|
raise Exception ('Liberando disco virtual despues del particionado: ERROR')
|
||||||
|
|
||||||
|
logger.debug ('losetup --find')
|
||||||
|
partloop, _ = utils.run (['losetup', '--find'])
|
||||||
|
if not partloop:
|
||||||
|
raise Exception ('no partloop')
|
||||||
|
|
||||||
|
logger.debug ('losetup --offset attach')
|
||||||
|
utils.run (['losetup', '--offset', '32256', partloop, btrootfsimg])
|
||||||
|
|
||||||
|
logger.info ('Creating ext4 filesystem')
|
||||||
|
try: utils.run (['mkfs.ext4', '-b', '4096', '-L', btrootfsimglabel, partloop])
|
||||||
|
except:
|
||||||
|
raise Exception ('Formateando la particion principal del disco virtual: ERROR')
|
||||||
|
|
||||||
|
time.sleep (3)
|
||||||
|
logger.debug ('losetup --detach')
|
||||||
|
try: utils.run (['losetup', '--detach', partloop])
|
||||||
|
except:
|
||||||
|
raise Exception ('Liberando la particion virtual despues del formateo: ERROR')
|
||||||
|
|
||||||
|
logger.info (f'"{btrootfsimg}" "{btvirtualdisksize}" MB : OK')
|
||||||
|
|
||||||
|
# works on an already mounted rootfs
|
||||||
|
def debootstrap (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp):
|
||||||
|
logger.info ('Iniciando la generación del sistema de archivos')
|
||||||
|
|
||||||
|
logger.info ('debootstrapping system')
|
||||||
|
logger.debug (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}"')
|
||||||
|
try: utils.run (['debootstrap', f'--arch={osarch}', '--components=main,universe', oscodename, btrootfsmnt, oshttp])
|
||||||
|
except: raise Exception (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ha fallado!')
|
||||||
|
|
||||||
|
logger.info (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ok')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def copy_og_files (builder, og_shared, og_engine, ogclientmount, osdistrib, oscodename):
|
||||||
|
logger.info ('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 ssh_server (btrootfsmnt):
|
||||||
|
if not os.path.exists ('/root/.ssh/id_rsa'): ## creates a key pair in the VM (or docker container), not in the chroot
|
||||||
|
utils.run (['ssh-keygen', '-q', '-f', '/root/.ssh/id_rsa', '-N', ''])
|
||||||
|
|
||||||
|
logger.debug ('comprobando directorio .ssh del root')
|
||||||
|
if not os.path.exists (f'{btrootfsmnt}/root/.ssh'): ## creates directory within the chroot
|
||||||
|
logger.debug ('creando directorio .ssh 600')
|
||||||
|
os.mkdir (f'{btrootfsmnt}/root/.ssh')
|
||||||
|
os.chmod (f'{btrootfsmnt}/root/.ssh', 0o700)
|
||||||
|
|
||||||
|
logger.debug ('creando el fichero authorized_keys') ## creates file within the chroot
|
||||||
|
if not os.path.exists (f'{btrootfsmnt}/root/.ssh/authorized_keys'):
|
||||||
|
open (f'{btrootfsmnt}/root/.ssh/authorized_keys', 'w').close()
|
||||||
|
os.chmod (f'{btrootfsmnt}/root/.ssh/authorized_keys', 0o600)
|
||||||
|
|
||||||
|
logger.debug ('importando la clave publica del servidor OG')
|
||||||
|
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
|
||||||
|
fdin = open ('/root/.ssh/id_rsa.pub', 'r')
|
||||||
|
fdout = open (f'{btrootfsmnt}/root/.ssh/authorized_keys', 'a')
|
||||||
|
while True:
|
||||||
|
l = fdin.readline()
|
||||||
|
if not l: break
|
||||||
|
fdout.write (l)
|
||||||
|
fdin.close()
|
||||||
|
fdout.close()
|
||||||
|
|
||||||
|
else:
|
||||||
|
logger.error ('no key publica og')
|
||||||
|
|
||||||
|
def ssh_client (btrootfsmnt):
|
||||||
|
if not os.path.exists (f'{btrootfsmnt}/root/.ssh/id_rsa'):
|
||||||
|
utils.run (['ssh-keygen', '-q', '-f', f'{btrootfsmnt}/root/.ssh/id_rsa', '-N', '']) ## creates a key pair in the chroot
|
||||||
|
|
||||||
|
#cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys ## takes the pubkey and authorises it to itself
|
||||||
|
fdin = open (f'{btrootfsmnt}//root/.ssh/id_rsa.pub', 'r')
|
||||||
|
fdout = open (f'{btrootfsmnt}/root/.ssh/authorized_keys', 'a')
|
||||||
|
while True:
|
||||||
|
l = fdin.readline()
|
||||||
|
if not l: break
|
||||||
|
fdout.write (l)
|
||||||
|
fdin.close()
|
||||||
|
fdout.close()
|
||||||
|
|
||||||
|
## TODO: exportamos la publica a los repos
|
||||||
|
#cp /root/.ssh/id_rsa.pub /tmp/rsa.ogclient.pub
|
||||||
|
|
||||||
|
def move_initrd (bttargetdir, osrelease):
|
||||||
|
## backup de oginitrd.img, oginitrd.img.sum, ogvmlinuz y ogvmlinuz.sum
|
||||||
|
now = datetime.datetime.now(datetime.timezone.utc).strftime ('%Y%m%d-%H%M%S%z')
|
||||||
|
if os.path.exists (f'{bttargetdir}/oginitrd.img'):
|
||||||
|
os.rename (f'{bttargetdir}/oginitrd.img' , f'{bttargetdir}/oginitrd.img.{now}')
|
||||||
|
os.rename (f'{bttargetdir}/oginitrd.img.sum', f'{bttargetdir}/oginitrd.img.sum.{now}')
|
||||||
|
if os.path.exists (f'{bttargetdir}/ogvmlinuz'):
|
||||||
|
os.rename (f'{bttargetdir}/ogvmlinuz' , f'{bttargetdir}/ogvmlinuz.{now}')
|
||||||
|
os.rename (f'{bttargetdir}/ogvmlinuz.sum', f'{bttargetdir}/ogvmlinuz.sum.{now}')
|
||||||
|
|
||||||
|
shutil.copy (f'/tmp/initrd.img-{osrelease}', f'{bttargetdir}/oginitrd.img')
|
||||||
|
shutil.copy (f'/tmp/vmlinuz-{osrelease}', f'{bttargetdir}/ogvmlinuz')
|
||||||
|
|
||||||
|
utils.write_md5 (f'{bttargetdir}/oginitrd.img')
|
||||||
|
utils.write_md5 (f'{bttargetdir}/ogvmlinuz')
|
||||||
|
|
||||||
|
#chmod -R 755 $BTTARGETDIR
|
||||||
|
for f in glob.glob (f'{bttargetdir}/oginitrd*') + glob.glob (f'{bttargetdir}/vmlinuz*'):
|
||||||
|
os.chmod (f, 0o755)
|
||||||
|
|
||||||
|
def mksquashfs (bttargetdir, btrootfsmnt):
|
||||||
|
logger.info ('Iniciando la creación del sistema de archivos en sqfs')
|
||||||
|
|
||||||
|
if os.path.exists (f'{bttargetdir}/ogclient.sqfs'):
|
||||||
|
now = datetime.datetime.now(datetime.timezone.utc).strftime ('%Y%m%d-%H%M%S%z')
|
||||||
|
os.rename (f'{bttargetdir}/ogclient.sqfs', f'{bttargetdir}/ogclient.sqfs.{now}')
|
||||||
|
|
||||||
|
## uses all CPU cores available, even within docker
|
||||||
|
utils.run (['mksquashfs', btrootfsmnt, f'{bttargetdir}/ogclient.sqfs', '-e', 'var/lib/apt/lists', '-e', 'usr/share/doc'])
|
||||||
|
os.chmod (f'{bttargetdir}/ogclient.sqfs', 0o744)
|
||||||
|
|
||||||
|
utils.write_md5 (f'{bttargetdir}/ogclient.sqfs')
|
||||||
|
|
||||||
|
def mkisofs (pxepkg, isolinux_tpl, bttargetdir, nameisoclient):
|
||||||
|
#Preparamos los gestores de arranque
|
||||||
|
try: os.makedirs ('/tmp/iso/isolinux', exist_ok=True)
|
||||||
|
except: raise
|
||||||
|
|
||||||
|
subprocess.run (['cp -a /usr/lib/syslinux/* /tmp/iso/isolinux/'], shell=True)
|
||||||
|
|
||||||
|
if 'gpxe' == pxepkg:
|
||||||
|
subprocess.run (['cp -a /usr/share/gpxe/* /tmp/iso/isolinux'], shell=True)
|
||||||
|
elif 'ipxe' == pxepkg:
|
||||||
|
subprocess.run (['cp -a /usr/lib/ipxe/* /tmp/iso/isolinux'], shell=True)
|
||||||
|
else:
|
||||||
|
raise Exception (f'unknown pxepkg value "{pxepkg}"')
|
||||||
|
|
||||||
|
# Si existe el fichero ISO, montarlo para extraer isolinux.bin.
|
||||||
|
if os.path.exists (f'/tmp/iso/isolinux/{pxepkg}.iso'):
|
||||||
|
os.mkdir ('/tmp/iso/isolinux/mount')
|
||||||
|
utils.run (['mount', '-o', 'loop', f'/tmp/iso/isolinux/{pxepkg}.iso', '/tmp/iso/isolinux/mount'])
|
||||||
|
subprocess.run (['cp -a /tmp/iso/isolinux/mount/* /tmp/iso/isolinux'], shell=True)
|
||||||
|
utils.umount ('/tmp/iso/isolinux/mount')
|
||||||
|
os.rmdir ('/tmp/iso/isolinux/mount')
|
||||||
|
os.unlink (f'/tmp/iso/isolinux/{pxepkg}.iso')
|
||||||
|
|
||||||
|
with open ('/tmp/iso/isolinux/isolinux.cfg', 'w') as fd:
|
||||||
|
fd.write (isolinux_tpl.strip().replace('__NAMEISOCLIENT__', nameisoclient).replace('__PXEPKG__', pxepkg))
|
||||||
|
|
||||||
|
# preparamos el directorio boot-tools.
|
||||||
|
if not os.path.exists ('/tmp/iso/ogclient'):
|
||||||
|
os.mkdir ('/tmp/iso/ogclient')
|
||||||
|
shutil.copy (f'{bttargetdir}/ogclient.sqfs', '/tmp/iso/ogclient/')
|
||||||
|
shutil.copy (f'{bttargetdir}/ogclient.sqfs.sum', '/tmp/iso/ogclient/')
|
||||||
|
shutil.copy (f'{bttargetdir}/ogvmlinuz', '/tmp/iso/ogclient/')
|
||||||
|
shutil.copy (f'{bttargetdir}/ogvmlinuz.sum', '/tmp/iso/ogclient/')
|
||||||
|
shutil.copy (f'{bttargetdir}/ogvmlinuz', '/tmp/iso/ogclient/linuxISO')
|
||||||
|
shutil.copy (f'{bttargetdir}/ogvmlinuz.sum', '/tmp/iso/ogclient/linuxISO.sum')
|
||||||
|
shutil.copy (f'{bttargetdir}/oginitrd.img', '/tmp/iso/ogclient/')
|
||||||
|
shutil.copy (f'{bttargetdir}/oginitrd.img.sum', '/tmp/iso/ogclient/')
|
||||||
|
#el ogclienteToISO debe tener una copia del ogvmlinuz como linuxISO
|
||||||
|
#cp -prv /var/lib/tftpboot/ogclientToIso/* /tmp/iso/ogclient
|
||||||
|
|
||||||
|
oldpwd = os.getcwd()
|
||||||
|
os.chdir ('/tmp')
|
||||||
|
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')
|
||||||
|
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'])
|
||||||
|
|
||||||
|
utils.write_md5 (f'{nameisoclient}.iso')
|
||||||
|
os.chdir (oldpwd)
|
||||||
|
|
||||||
|
shutil.move (f'/tmp/{nameisoclient}.iso' , f'/var/lib/tftpboot/ogclient/{nameisoclient}.iso')
|
||||||
|
shutil.move (f'/tmp/{nameisoclient}.iso.sum', f'/var/lib/tftpboot/ogclient/{nameisoclient}.iso.sum')
|
||||||
|
|
||||||
|
#def __unused_boottoolsBootGraphics():
|
||||||
|
# find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null;
|
||||||
|
# apt-get -y install plymouth plymouth-theme-script
|
||||||
|
# update-alternatives --install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/opengnsys/opengnsys.plymouth 100
|
||||||
|
# update-alternatives --set default.plymouth /lib/plymouth/themes/opengnsys/opengnsys.plymouth
|
||||||
|
# mkdir -p /etc/initramfs-tools/conf.d
|
||||||
|
# echo "FRAMEBUFFER=y" > /etc/initramfs-tools/conf.d/splash
|
||||||
|
|
||||||
|
|
||||||
|
############### No usados en el instalador, solo en actualizaciones.
|
||||||
|
|
||||||
|
# ogClientMount [str_program]
|
||||||
|
#@brief Acceso al 2nd FS del cliente desde el Servidor Opengnsys
|
||||||
|
#@param 1 Opciona: scripts o programa a ejecutar para automatizaciones
|
||||||
|
#@return Si no hay parametros: login de acceso.
|
||||||
|
#@return con un parametro: La salida del programa ejecutado
|
||||||
|
#def ogClientMount():
|
||||||
|
# TODO comprobar que OGFILE y OGFILEMOUNT existe.
|
||||||
|
# mount | grep $OGCLIENTFILE > /dev/null || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256
|
||||||
|
# mount | grep $OGCLIENTMOUNT/proc > /dev/null || mount --bind /proc $OGCLIENTMOUNT/proc
|
||||||
|
# mount | grep $OGCLIENTMOUNT/sys > /dev/null || mount --bind /sys $OGCLIENTMOUNT/sys
|
||||||
|
# mount | grep $OGCLIENTMOUNT/tmp > /dev/null || mount --bind /tmp $OGCLIENTMOUNT/tmp
|
||||||
|
# mount | grep $OGCLIENTMOUNT/dev > /dev/null || mount --bind /dev $OGCLIENTMOUNT/dev
|
||||||
|
# mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null || mount --bind /dev/pts $OGCLIENTMOUNT/dev/pts
|
||||||
|
# [ $# = 0 ] && $(chroot $OGCLIENTMOUNT /sbin/getty 38400 `tty`)
|
||||||
|
# [ $# = 1 ] && chroot $OGCLIENTMOUNT $1
|
||||||
|
|
||||||
|
#@brief Desmonta el 2nd FS del cliente desde el Servidor Opengnsys
|
||||||
|
#def ogClientUnmount():
|
||||||
|
# cd /tmp
|
||||||
|
# echo "desmontando cliente espere"
|
||||||
|
# sleep 5
|
||||||
|
# mount | grep $OGCLIENTMOUNT/dev > /dev/null && umount $OGCLIENTMOUNT/dev || ogClientUnmount
|
||||||
|
# mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null && umount $OGCLIENTMOUNT/dev/pts || ogClientUnmount
|
||||||
|
# mount | grep $OGCLIENTMOUNT/proc > /dev/null && umount $OGCLIENTMOUNT/proc || ogClientUnmount
|
||||||
|
# mount | grep $OGCLIENTMOUNT/sys > /dev/null && umount $OGCLIENTMOUNT/sys || ogClientUnmount
|
||||||
|
# mount | grep $OGCLIENTMOUNT/tmp > /dev/null && umount $OGCLIENTMOUNT/tmp || ogClientUnmount
|
||||||
|
# mount | grep $OGCLIENTMOUNT > /dev/null && umount $OGCLIENTMOUNT || ogClientUnmount
|
|
@ -0,0 +1,80 @@
|
||||||
|
import logging
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
import configparser
|
||||||
|
import selectors
|
||||||
|
|
||||||
|
logger = logging.getLogger ('boottools')
|
||||||
|
|
||||||
|
def run (args):
|
||||||
|
stdout = stderr = ''
|
||||||
|
logger.debug ('run 10 args "{}"'.format (' '.join(args)))
|
||||||
|
sel = selectors.DefaultSelector()
|
||||||
|
p = subprocess.Popen (args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
|
sel.register (p.stdout.fileno(), selectors.EVENT_READ)
|
||||||
|
sel.register (p.stderr.fileno(), selectors.EVENT_READ)
|
||||||
|
while True:
|
||||||
|
events = sel.select()
|
||||||
|
for key, _ in events:
|
||||||
|
if key.fileobj == p.stdout.fileno():
|
||||||
|
line = p.stdout.readline()
|
||||||
|
if not line: break
|
||||||
|
stdout += line
|
||||||
|
logger.debug (line.rstrip())
|
||||||
|
elif key.fileobj == p.stderr.fileno():
|
||||||
|
line = p.stderr.readline()
|
||||||
|
if not line: break
|
||||||
|
stderr += line
|
||||||
|
logger.warn (line.rstrip())
|
||||||
|
if p.poll() != None:
|
||||||
|
break
|
||||||
|
sel.close()
|
||||||
|
stdout = stdout.strip()
|
||||||
|
stderr = stderr.strip()
|
||||||
|
|
||||||
|
logger.debug (f'p.returncode {p.returncode}')
|
||||||
|
if p.returncode:
|
||||||
|
logger.error ('command "{}" failed with rc "{}"'.format (' '.join(args), p.returncode))
|
||||||
|
|
||||||
|
#logger.error ('stdout follows:')
|
||||||
|
#if stdout:
|
||||||
|
# for i in stdout.split('\n'): logger.error (' ' + i)
|
||||||
|
|
||||||
|
logger.error ('stderr follows:')
|
||||||
|
if stderr:
|
||||||
|
for i in stderr.split('\n'): logger.error (' ' + i)
|
||||||
|
|
||||||
|
raise Exception ('command "{}" failed with rc "{}"'.format (' '.join(args), p.returncode))
|
||||||
|
return stdout, stderr
|
||||||
|
|
||||||
|
def grep (regex, file):
|
||||||
|
with open (file, 'r') as f:
|
||||||
|
for l in f:
|
||||||
|
if (re.findall (regex, l)): return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def is_mounted (mntpt):
|
||||||
|
return grep (mntpt, '/proc/mounts')
|
||||||
|
|
||||||
|
def mount (dev, mntpt, opts=[]):
|
||||||
|
if not is_mounted (mntpt):
|
||||||
|
run (['mount', dev, mntpt] + opts)
|
||||||
|
|
||||||
|
def umount (mntpt):
|
||||||
|
if (is_mounted (mntpt)):
|
||||||
|
run (['umount', mntpt])
|
||||||
|
|
||||||
|
def read_config (fn):
|
||||||
|
if not os.path.exists (fn):
|
||||||
|
print (f'configuration file "{fn}" not found')
|
||||||
|
return
|
||||||
|
config = configparser.ConfigParser (comment_prefixes='#', inline_comment_prefixes='#')
|
||||||
|
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')
|
|
@ -1,648 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#/**
|
|
||||||
#@file boottoolsfunctions.lib
|
|
||||||
#@brief Librería o clase Boot-Tools
|
|
||||||
#@class Boot-Tools
|
|
||||||
#@brief Funciones para generar un sistema operativo cliente para opengnsys
|
|
||||||
#@version 1.1.1
|
|
||||||
#@warning License: GNU GPLv3+
|
|
||||||
#*/
|
|
||||||
|
|
||||||
|
|
||||||
# btGetVariables: define las constantes a utilizar
|
|
||||||
# Autor: Antonio J. Doblas Viso. Universidad de Málaga.
|
|
||||||
function btogGetVar()
|
|
||||||
{
|
|
||||||
export BTDIR=/tmp/opengnsys_installer/opengnsys/client/boot-tools
|
|
||||||
export BTTARGETDIR=/var/lib/tftpboot/ogclient/
|
|
||||||
export BTROOTFSIMG=${BTTARGETDIR}ogclient.img
|
|
||||||
export BTROOTFSMNT=${BTTARGETDIR}ogclientmount
|
|
||||||
if [ "$OSARCH" = "i386" ]; then
|
|
||||||
# tamaño maximo limitado por schroot 2GB para 32 bits
|
|
||||||
export BTVIRTUALDISKSIZE=2000
|
|
||||||
else
|
|
||||||
export BTVIRTUALDISKSIZE="3G"
|
|
||||||
fi
|
|
||||||
export BTROOTFSIMGLABEL=ogClient
|
|
||||||
|
|
||||||
export LOG_FILE=/tmp/boot-tools_installation.log
|
|
||||||
|
|
||||||
export VERSIONBOOTTOOLS="ogLive"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# btGetOsInfo: detecta la version del host, para tenerla de referencia en el boot-tools a generar.
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
#@version 1.0.5 - Fichero general de configuración, Kernel 3.7 para Ubuntu 12.10.
|
|
||||||
#@author Ramón Gómez, ETSII Univ. Sevilla
|
|
||||||
#@date 2013/02/06
|
|
||||||
function btogGetOsInfo ()
|
|
||||||
{
|
|
||||||
OGCLIENTCFG=/tmp/ogclient.cfg
|
|
||||||
case "${1,,}" in
|
|
||||||
precise) # ogLive 1.0.4-rc2 basado en Ubuntu 12.04 LTS.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="precise"
|
|
||||||
OSRELEASE="3.2.0-23-generic"
|
|
||||||
#OSRELEASE="3.11.0-26-generic"
|
|
||||||
OSARCH="i386"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
wheezy) # ogLive basado en Debian 7.3.
|
|
||||||
OSDISTRIB="debian"
|
|
||||||
OSCODENAME="wheezy"
|
|
||||||
OSRELEASE="3.2.0-4-i386"
|
|
||||||
OSARCH="i386"
|
|
||||||
OSHTTP="http://ftp.es.debian.org/debian/"
|
|
||||||
;;
|
|
||||||
quantal) # ogLive 1.0.5-rc2 basado en Ubuntu 12.10 con Kernel descargado.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="quantal"
|
|
||||||
OSRELEASE="3.7.6-030706-generic"
|
|
||||||
OSARCH="i386"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
raring) # ogLive 1.0.5-rc3 basado en Ubuntu 13.04.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="raring"
|
|
||||||
OSRELEASE="3.8.0-22-generic"
|
|
||||||
OSARCH="i386"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
trusty) # ogLive 1.0.5-rc4 basado en Ubuntu 14.04.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="trusty"
|
|
||||||
OSRELEASE="3.13.0-24-generic"
|
|
||||||
OSARCH="i386"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
vivid) # ogLive 1.1.0-rc2 basado en Ubuntu 15.04.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="vivid"
|
|
||||||
OSRELEASE="3.19.0-49-generic"
|
|
||||||
OSARCH="i386"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
wily) # ogLive 1.1.0-rc1 basado en Ubuntu 15.10.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="wily"
|
|
||||||
OSRELEASE="4.2.0-35-generic"
|
|
||||||
OSARCH="i386"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
xenial|xenial-4.4) # ogLive 1.1.0-rc4 basado en Ubuntu 16.04 y Kernel 4.4.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="xenial"
|
|
||||||
OSRELEASE="4.4.0-34-generic"
|
|
||||||
OSARCH="i386"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
xenial-4.8) # ogLive 1.1.0-rc5 basado en Ubuntu 16.04 y Kernel 4.8.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="xenial"
|
|
||||||
OSRELEASE="4.8.0-39-generic"
|
|
||||||
OSARCH="amd64"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
xenial-4.13) # ogLive 1.1.0-rc6 basado en Ubuntu 16.04 y Kernel 4.13.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="xenial"
|
|
||||||
OSRELEASE="4.13.0-17-generic"
|
|
||||||
OSARCH="amd64"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
bionic|bionic-4.15) # ogLive 1.1.1-rc1 basado en Ubuntu 18.04 y Kernel 4.15.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="bionic"
|
|
||||||
OSRELEASE="4.15.0-32-generic"
|
|
||||||
OSARCH="amd64"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
bionic-4.18) # ogLive 1.1.1-rc3 basado en Ubuntu 18.04 y Kernel 4.18.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="bionic"
|
|
||||||
OSRELEASE="4.18.0-20-generic"
|
|
||||||
OSARCH="amd64"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
bionic-5.0) # ogLive 1.1.1-rc5 basado en Ubuntu 18.04 y Kernel 5.0.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="bionic"
|
|
||||||
OSRELEASE="5.0.0-27-generic"
|
|
||||||
OSARCH="amd64"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
focal) # ogLive 1.2.0-rc1 basado en Ubuntu 20.04 y Kernel 5.4.
|
|
||||||
OSDISTRIB="ubuntu"
|
|
||||||
OSCODENAME="focal"
|
|
||||||
OSRELEASE="5.4.0-42-generic"
|
|
||||||
OSARCH="amd64"
|
|
||||||
OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
host) # ogLive basado en la distribución del servidor.
|
|
||||||
OSDISTRIB=$(lsb_release -is)
|
|
||||||
OSCODENAME=$(lsb_release -cs)
|
|
||||||
OSRELEASE=$(uname -r)
|
|
||||||
OSARCH=$(dpkg --print-architecture)
|
|
||||||
export OSHTTP="http://es.archive.ubuntu.com/ubuntu/"
|
|
||||||
;;
|
|
||||||
*) # Parámetro desconocido
|
|
||||||
echo "Parámetro no válido."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
BRANCH="master"
|
|
||||||
GITURL="https://api.github.com/repos/opengnsys/OpenGnsys/commits?sha=$BRANCH&path=/client"
|
|
||||||
GITRELEASE=$(curl -s "$GITURL" | jq -r '"r" + (.[0].commit.committer.date | split("-") | join("")[:8]) + "." + (.[0].sha[:7])')
|
|
||||||
NAMEISOCLIENT="$VERSIONBOOTTOOLS-$OSCODENAME-$OSRELEASE-$OSARCH-$GITRELEASE"
|
|
||||||
NAMEHOSTCLIENT="$VERSIONBOOTTOOLS-$OSCODENAME-$GITRELEASE"
|
|
||||||
export OSDISTRIB OSCODENAME OSRELEASE OSARCH OSHTTP
|
|
||||||
export TYPECLIENT GITRELEASE NAMEISOCLIENT NAMEHOSTCLIENT
|
|
||||||
### El fichero de configuración debe sustituir a estos 3 ficheros (borrar las 3 líneas siguientes).
|
|
||||||
echo "$NAMEISOCLIENT" > /tmp/opengnsys_info_rootfs
|
|
||||||
echo "$NAMEHOSTCLIENT" > /tmp/opengnsys_chroot
|
|
||||||
# Generar fichero de configuración.
|
|
||||||
cat << EOT > $OGCLIENTCFG
|
|
||||||
TYPECLIENT="$1"
|
|
||||||
OSDISTRIB="$OSDISTRIB"
|
|
||||||
OSCODENAME="$OSCODENAME"
|
|
||||||
OSRELEASE="$OSRELEASE"
|
|
||||||
OSARCH="$OSARCH"
|
|
||||||
OSHTTP="$OSHTTP"
|
|
||||||
GITRELEASE="$GITRELEASE"
|
|
||||||
NAMEISOCLIENT="$NAMEISOCLIENT"
|
|
||||||
NAMEHOSTCLIENT="$NAMEHOSTCLIENT"
|
|
||||||
EOT
|
|
||||||
}
|
|
||||||
|
|
||||||
# btogSetFsVirtual: Crea y formatea el fichero - disco duro virtual
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
# error code return 2
|
|
||||||
function btogSetFsVirtual ()
|
|
||||||
{
|
|
||||||
|
|
||||||
local RERROR DISKLOOP PARTLOOP #return code error
|
|
||||||
|
|
||||||
#Dependencias.
|
|
||||||
[ -z "$BTROOTFSIMG" ] && btogGetVar
|
|
||||||
|
|
||||||
echoAndLog "$FUNCNAME(): Creación y formateo del disco virtual $BTVIRTUALDISKSIZE MB "
|
|
||||||
|
|
||||||
#Desmontamos el dispositivo virtual
|
|
||||||
mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT
|
|
||||||
mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT
|
|
||||||
|
|
||||||
#echo "$FUNCNAME(): Creando el directorio donde se montará el disco virtual $BTROOTFSMNT"
|
|
||||||
mkdir -p $BTROOTFSMNT
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
errorAndLog "$FUNCNAME(): Creando directorio $BTROOTFSMNT : ERROR"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Permisos para el usuario opengnsys.
|
|
||||||
chown -R root:opengnsys $BTTARGETDIR
|
|
||||||
|
|
||||||
#echo "$FUNCNAME(): Creando el disco virtual con tamaño máximo de $BTVIRTUALDISKSIZE MB"
|
|
||||||
if [ "$OSARCH" = "i386" ]; then
|
|
||||||
dd if=/dev/zero of=$BTROOTFSIMG bs=1048576 count=$BTVIRTUALDISKSIZE
|
|
||||||
#dd if=/dev/zero of=$BTROOTFSIMG bs=1k count=$OGCLIENTSIZEKB # necesita 500MB
|
|
||||||
else
|
|
||||||
qemu-img create $BTROOTFSIMG $BTVIRTUALDISKSIZE
|
|
||||||
fi
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
errorAndLog "$FUNCNAME(): Creando el disco virtual con tamaño maxima $BTVIRTUALDISKSIZE MB : ERROR"
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Particionamos el disco virtual con una sola particion primaria.
|
|
||||||
DISKLOOP=$(losetup -f)
|
|
||||||
#TODO: si no DISKLOOP error
|
|
||||||
losetup $DISKLOOP $BTROOTFSIMG
|
|
||||||
#echo "$FUNCNAME(): particiondo el disco virtual - $DISKLOOP - con una particion primaria"
|
|
||||||
echo -e "n\np\n1\n\n\nt\n83\nw" | fdisk $DISKLOOP
|
|
||||||
|
|
||||||
|
|
||||||
#echoAndLog "$FUNCNAME(): Liberamos Desmontando $DISKLOOP despues del particionado "
|
|
||||||
sleep 10
|
|
||||||
losetup -d $DISKLOOP
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
errorAndLog "$FUNCNAME(): Liberando disco virtual despues del particionado: ERROR"
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
PARTLOOP=$(losetup -f)
|
|
||||||
#echo "$FUNCNAME(): Formateando la particion principal $PARTLOOP"
|
|
||||||
losetup -o 32256 $PARTLOOP $BTROOTFSIMG && mkfs.ext4 -b 4096 -L $BTROOTFSIMGLABEL $PARTLOOP
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
errorAndLog "$FUNCNAME(): Formateando la particion principal del disco virtual: ERROR"
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
#echoAndLog "$FUNCNAME(): Desmontando $PARTLOOP despues del formateo "
|
|
||||||
sleep 10
|
|
||||||
losetup -d $PARTLOOP
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
errorAndLog "$FUNCNAME(): Liberando la particion virtual despues del formateo: ERROR"
|
|
||||||
return 2
|
|
||||||
else
|
|
||||||
echoAndLog "$FUNCNAME(): $BTROOTFSIMG $BTVIRTUALDISKSIZE MB : OK"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# btogSetfsBase: Genera el sistema root base con debootstrap
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
# error code return 3
|
|
||||||
function btogSetFsBase ()
|
|
||||||
{
|
|
||||||
|
|
||||||
# Dependencias
|
|
||||||
[ -z "$OSCODENAME" ] && btogGetOsInfo $TYPECLIENT
|
|
||||||
|
|
||||||
echoAndLog "$FUNCNAME: Iniciando la generación del sistema de archivos "
|
|
||||||
|
|
||||||
#Montamos el dispositivo virtual en su punto de montaje.
|
|
||||||
mount | grep $BTROOTFSMNT || mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256
|
|
||||||
mount | grep $BTROOTFSMNT && echoAndLog "$FUNCNAME: mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256 OK " || errorAndLog "$FUNCNAME: mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256 : FAILURE "
|
|
||||||
|
|
||||||
debootstrap --arch=$OSARCH --components=main,universe ${OSCODENAME} ${BTROOTFSMNT} ${OSHTTP}
|
|
||||||
#debootstrap --arch=$OSARCH ${OSCODENAME} ${BTROOTFSMNT} http://archive.ubuntu.com/ubuntu/
|
|
||||||
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
errorAndLog "$FUNCNAME: debootstrap --arch=$OSARCH --components=main,universe $OSCODENAME $BTROOTFSMNT $OSHTTP : ha fallado!"
|
|
||||||
mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT
|
|
||||||
return 3
|
|
||||||
else
|
|
||||||
echoAndLog "$FUNCNAME: debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe $OSCODENAME $BTROOTFSMNT $OSHTTP : ok"
|
|
||||||
mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
##preubas revisar OSRELEASE
|
|
||||||
#debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe ${OSCODENAME} ${OGCLIENTMOUNT} ${OSHTTP}
|
|
||||||
#debootstrap --include=linux-image-${OSRELEASE} --arch=i386 --variant=minbase $OSVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/
|
|
||||||
#debootstrap --variant=minbase --include=linux-image-${OGRELEASE} --arch=i386 $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/
|
|
||||||
#echo debootstrap --include=linux-image-${OGRELEASE},dbus --arch=i386 --components=main,universe $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/
|
|
||||||
}
|
|
||||||
|
|
||||||
#btogSetFsAcces: habilita el acceso al sistema root del cliente con schroot
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
function btogSetFsAccess()
|
|
||||||
{
|
|
||||||
echoAndLog "$FUNCNAME: Iniciando la configuración del schroot "
|
|
||||||
cp /etc/schroot/schroot.conf /etc/schroot/schroot.conf.`getDateTime`
|
|
||||||
cat << EOF > /etc/schroot/schroot.conf
|
|
||||||
[IMGogclient]
|
|
||||||
type=loopback
|
|
||||||
file=/var/lib/tftpboot/ogclient/ogclient.img
|
|
||||||
description=ogclient Ubuntu image
|
|
||||||
#priority=1
|
|
||||||
users=root
|
|
||||||
groups=root
|
|
||||||
root-groups=root
|
|
||||||
mount-options=-o offset=32256
|
|
||||||
root-users=root
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cp /etc/schroot/mount-defaults /etc/schroot/mount-defaults.`getDateTime`
|
|
||||||
cat << EOF > /etc/schroot/mount-defaults
|
|
||||||
# mount.defaults: static file system information for chroots.
|
|
||||||
# Note that the mount point will be prefixed by the chroot path
|
|
||||||
# (CHROOT_PATH)
|
|
||||||
#
|
|
||||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
||||||
proc /proc proc defaults 0 0
|
|
||||||
#procbususb /proc/bus/usb usbfs defaults 0 0
|
|
||||||
#/dev /dev none rw,bind 0 0
|
|
||||||
/dev/pts /dev/pts none rw,bind 0 0
|
|
||||||
/dev/shm /dev/shm none rw,bind 0 0
|
|
||||||
#/home /home none rw,bind 0 0
|
|
||||||
/tmp /tmp none rw,bind 0 0
|
|
||||||
EOF
|
|
||||||
|
|
||||||
rm /etc/schroot/setup.d/*chrootname
|
|
||||||
|
|
||||||
echoAndLog "$FUNCNAME: Finalizado: OK "
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#btogFsInitr genera un initrd.
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
function btogFsInitrd ()
|
|
||||||
{
|
|
||||||
#DEPENDENCIAS
|
|
||||||
[ -z "$BTROOTFSIMG" ] && btogGetVar
|
|
||||||
[ -z "$OSCODENAME" ] && btogGetOsInfo $TYPECLIENT
|
|
||||||
|
|
||||||
cd /
|
|
||||||
schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsInitrdGenerate.sh
|
|
||||||
echo "cp /tmp/*-${OSRELEASE} ${BTTARGETDIR}"
|
|
||||||
cp /tmp/*-${OSRELEASE} ${BTTARGETDIR}
|
|
||||||
#Creando copias de las version oginitr y ogvmlinux previas
|
|
||||||
TIMEMOD=`date +%Y%m%d-%H%M%S`
|
|
||||||
[ -f $BTTARGETDIR/oginitrd.img ] && mv $BTTARGETDIR/oginitrd.img $BTTARGETDIR/oginitrd.img.$TIMEMOD; mv $BTTARGETDIR/oginitrd.img.sum $BTTARGETDIR/oginitrd.img.sum.$TIMEMOD
|
|
||||||
[ -f $BTTARGETDIR/ogvmlinuz ] && mv $BTTARGETDIR/ogvmlinuz $BTTARGETDIR/ogvmlinuz.$TIMEMOD; mv $BTTARGETDIR/ogvmlinuz.sum $BTTARGETDIR/ogvmlinuz.sum.$TIMEMOD
|
|
||||||
|
|
||||||
#copiando
|
|
||||||
cp /tmp/initrd.img-${OSRELEASE} ${BTTARGETDIR}/oginitrd.img
|
|
||||||
cp /tmp/vmlinuz-${OSRELEASE} ${BTTARGETDIR}/ogvmlinuz
|
|
||||||
#generamos md5 del kernel y del initrd.
|
|
||||||
DATASUM=`md5sum "${BTTARGETDIR}/oginitrd.img" | cut -f1 -d" "`
|
|
||||||
echo $DATASUM > ${BTTARGETDIR}/oginitrd.img.sum
|
|
||||||
DATASUM=`md5sum "${BTTARGETDIR}/ogvmlinuz" | cut -f1 -d" "`
|
|
||||||
echo $DATASUM > ${BTTARGETDIR}/ogvmlinuz.sum
|
|
||||||
#Damos permisos
|
|
||||||
cd -
|
|
||||||
chmod -R 755 $BTTARGETDIR
|
|
||||||
}
|
|
||||||
|
|
||||||
#btogFsSqfs convierte el sistema root en sqfs
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
function btogFsSqfs ()
|
|
||||||
{
|
|
||||||
#Dependencias.
|
|
||||||
[ -z "$BTROOTFSIMG" ] && btogGetVar
|
|
||||||
[ -z "$OSCODENAME" ] && btogGetOsInfo $TYPECLIENT
|
|
||||||
|
|
||||||
echoAndLog "$FUNCNAME: Iniciando la creación del sistema de archivos en sqfs "
|
|
||||||
# si ya existe un sqfs lo renombramos
|
|
||||||
[ -f $BTTARGETDIR/ogclient.sqfs ] && mv $BTTARGETDIR/ogclient.sqfs $BTTARGETDIR/ogclient.sqfs.`date +%Y%m%d-%H%M%S`
|
|
||||||
mount | grep $BTROOTFSMNT || mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256
|
|
||||||
mksquashfs $BTROOTFSMNT $BTTARGETDIR/ogclient.sqfs
|
|
||||||
mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT
|
|
||||||
chmod 744 $BTTARGETDIR/ogclient.sqfs
|
|
||||||
DATASUM=`md5sum "${BTTARGETDIR}/ogclient.sqfs" | cut -f1 -d" "`
|
|
||||||
echo $DATASUM > ${BTTARGETDIR}/ogclient.sqfs.sum
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# btogIsoGenerator genera la iso del cliente
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
function btogIsoGenerator {
|
|
||||||
#Dependencias.
|
|
||||||
#[ -z "$BTROOTFSIMG" ] && btogGetVar
|
|
||||||
btogGetVar
|
|
||||||
#Preparamos los gestores de arranque
|
|
||||||
mkdir -p /tmp/iso/isolinux
|
|
||||||
cp -av /usr/lib/syslinux/* /tmp/iso/isolinux/
|
|
||||||
if [ -d /usr/share/gpxe ]; then
|
|
||||||
cp -av /usr/share/gpxe/* /tmp/iso/isolinux
|
|
||||||
PXE=gpxe
|
|
||||||
elif [ -d /usr/lib/ipxe ]; then
|
|
||||||
cp -av /usr/lib/ipxe/* /tmp/iso/isolinux
|
|
||||||
PXE=ipxe
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Si existe el fichero ISO, montarlo para extraer isolinux.bin.
|
|
||||||
if [ -f /tmp/iso/isolinux/$PXE.iso ]; then
|
|
||||||
mkdir -p /tmp/iso/isolinux/mount
|
|
||||||
mount -o loop /tmp/iso/isolinux/$PXE.iso /tmp/iso/isolinux/mount
|
|
||||||
cp -va /tmp/iso/isolinux/mount/* /tmp/iso/isolinux
|
|
||||||
umount /tmp/iso/isolinux/mount
|
|
||||||
rmdir /tmp/iso/isolinux/mount
|
|
||||||
rm -f /tmp/iso/isolinux/$PXE.iso
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat << FIN > /tmp/iso/isolinux/isolinux.cfg
|
|
||||||
DEFAULT menu.c32
|
|
||||||
PROMPT 0
|
|
||||||
ALLOWOPTIONS 1
|
|
||||||
|
|
||||||
MENU TITLE OpenGnsys ${NAMEISOCLIENT}
|
|
||||||
|
|
||||||
|
|
||||||
LABEL 0
|
|
||||||
MENU LABEL ogLive vga irqpool acpi ogdebug ip:none
|
|
||||||
KERNEL /ogclient/linuxISO
|
|
||||||
APPEND initrd=/ogclient/oginitrd.img ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none
|
|
||||||
|
|
||||||
LABEL 1
|
|
||||||
MENU LABEL ogLive irqpoll acpi ip:none
|
|
||||||
KERNEL /ogclient/linuxISO
|
|
||||||
APPEND initrd=/ogclient/oginitrd.img ro irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=none
|
|
||||||
|
|
||||||
LABEL 2
|
|
||||||
MENU LABEL ogLive acpi debug ip=dhcp
|
|
||||||
KERNEL /ogclient/linuxISO
|
|
||||||
APPEND initrd=/ogclient/oginitrd.img ro acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=dhcp
|
|
||||||
|
|
||||||
LABEL 3
|
|
||||||
MENU LABEL ogLive ip=dhcp
|
|
||||||
KERNEL /ogclient/linuxISO
|
|
||||||
APPEND initrd=/ogclient/oginitrd.img ro acpi=off boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=dhcp
|
|
||||||
|
|
||||||
LABEL 4
|
|
||||||
MENU LABEL local
|
|
||||||
localboot 0x80
|
|
||||||
append -
|
|
||||||
|
|
||||||
label 5
|
|
||||||
MENU LABEL Network boot via gPXE lkrn
|
|
||||||
KERNEL $PXE.lkrn
|
|
||||||
|
|
||||||
label 6
|
|
||||||
MENU LABEL Network boot via gPXE usb
|
|
||||||
KERNEL $PXE.usb
|
|
||||||
|
|
||||||
label 7
|
|
||||||
MENU LABEL Network boot via gPXE pxe
|
|
||||||
KERNEL $PXE.pxe
|
|
||||||
|
|
||||||
label 8
|
|
||||||
MENU LABEL Network boot via gPXE iso
|
|
||||||
KERNEL $PXE.iso
|
|
||||||
|
|
||||||
label 9
|
|
||||||
MENU LABEL pxe
|
|
||||||
KERNEL /clonezilla/live/vmlinuz1
|
|
||||||
APPEND initrd=/clonezilla/live/initrd1.img boot=live union=aufs noswap vga=788 ip=frommedia
|
|
||||||
FIN
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# preparamos el directorio boot-tools.
|
|
||||||
mkdir -p /tmp/iso/ogclient
|
|
||||||
cp ${BTTARGETDIR}/ogclient.sqfs /tmp/iso/ogclient/
|
|
||||||
cp ${BTTARGETDIR}/ogclient.sqfs.sum /tmp/iso/ogclient/
|
|
||||||
cp ${BTTARGETDIR}/ogvmlinuz /tmp/iso/ogclient/
|
|
||||||
cp ${BTTARGETDIR}/ogvmlinuz.sum /tmp/iso/ogclient/
|
|
||||||
cp ${BTTARGETDIR}/ogvmlinuz /tmp/iso/ogclient/linuxISO
|
|
||||||
cp ${BTTARGETDIR}/ogvmlinuz.sum /tmp/iso/ogclient/linuxISO.sum
|
|
||||||
cp ${BTTARGETDIR}/oginitrd.img /tmp/iso/ogclient/
|
|
||||||
cp ${BTTARGETDIR}/oginitrd.img.sum /tmp/iso/ogclient/
|
|
||||||
#el ogclienteToISO debe tener una copia del ogvmlinuz como linuxISO
|
|
||||||
#cp -prv /var/lib/tftpboot/ogclientToIso/* /tmp/iso/ogclient
|
|
||||||
|
|
||||||
cd /tmp
|
|
||||||
#TIMEMOD=`date +%Y%m%d-%H%M%S`
|
|
||||||
####Generamos la iso
|
|
||||||
echo "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"
|
|
||||||
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
|
|
||||||
##Generamos el md5
|
|
||||||
DATASUM=`md5sum ${NAMEISOCLIENT}.iso | cut -f1 -d" "`
|
|
||||||
echo $DATASUM > ${NAMEISOCLIENT}.iso.sum
|
|
||||||
|
|
||||||
mv /tmp/${NAMEISOCLIENT}.iso /var/lib/tftpboot/ogclient/
|
|
||||||
mv /tmp/${NAMEISOCLIENT}.iso.sum /var/lib/tftpboot/ogclient/
|
|
||||||
|
|
||||||
|
|
||||||
### vi /etc/grub.d/40_custom
|
|
||||||
##
|
|
||||||
#menuentry "og cache " {
|
|
||||||
#set root=(hd0,4)
|
|
||||||
#linux /ogvmlinuz ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none
|
|
||||||
#initrd /oginitrd.img
|
|
||||||
#}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
function btogIsoTest {
|
|
||||||
#/tmp/iso
|
|
||||||
qemu -m 256 -boot d -cdrom ogClient.iso
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getDateTime()
|
|
||||||
{
|
|
||||||
echo `date +%Y%m%d-%H%M%S`
|
|
||||||
}
|
|
||||||
|
|
||||||
# Escribe a fichero y muestra por pantalla
|
|
||||||
function echoAndLog()
|
|
||||||
{
|
|
||||||
echo $1
|
|
||||||
FECHAHORA=`getDateTime`
|
|
||||||
echo "$FECHAHORA;$SSH_CLIENT;$1" >> $LOG_FILE
|
|
||||||
}
|
|
||||||
|
|
||||||
function errorAndLog()
|
|
||||||
{
|
|
||||||
echo "ERROR: $1"
|
|
||||||
FECHAHORA=`getDateTime`
|
|
||||||
echo "$FECHAHORA;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############### No usados en el instalador, solo en actualizaciones.
|
|
||||||
#/**
|
|
||||||
# ogClientMount [str_program]
|
|
||||||
#@brief Acceso al 2nd FS del cliente desde el Servidor Opengnsys
|
|
||||||
#@param 1 Opciona: scripts o programa a ejecutar para automatizaciones
|
|
||||||
#@return Si no hay parametros: login de acceso.
|
|
||||||
#@return con un parametro: La salida del programa ejecutado
|
|
||||||
#@exception
|
|
||||||
#@note
|
|
||||||
#@todo
|
|
||||||
#@version 0.9 - Primera versión para OpenGnSys
|
|
||||||
#@author Antonio J. Doblas Viso, Universidad de Málaga
|
|
||||||
#@date 2010/02/15
|
|
||||||
#*/ ##
|
|
||||||
function ogClientMount ()
|
|
||||||
{
|
|
||||||
#TODO comprobar que OGFILE y OGFILEMOUNT existe.
|
|
||||||
mount | grep $OGCLIENTFILE > /dev/null || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256
|
|
||||||
mount | grep $OGCLIENTMOUNT/proc > /dev/null || mount --bind /proc $OGCLIENTMOUNT/proc
|
|
||||||
mount | grep $OGCLIENTMOUNT/sys > /dev/null || mount --bind /sys $OGCLIENTMOUNT/sys
|
|
||||||
mount | grep $OGCLIENTMOUNT/tmp > /dev/null || mount --bind /tmp $OGCLIENTMOUNT/tmp
|
|
||||||
mount | grep $OGCLIENTMOUNT/dev > /dev/null || mount --bind /dev $OGCLIENTMOUNT/dev
|
|
||||||
mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null || mount --bind /dev/pts $OGCLIENTMOUNT/dev/pts
|
|
||||||
|
|
||||||
|
|
||||||
[ $# = 0 ] && $(chroot $OGCLIENTMOUNT /sbin/getty 38400 `tty`)
|
|
||||||
[ $# = 1 ] && chroot $OGCLIENTMOUNT $1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#/**
|
|
||||||
# ogClientUnmount
|
|
||||||
#@brief Desmonta el 2nd FS del cliente desde el Servidor Opengnsys
|
|
||||||
#@param
|
|
||||||
#@return
|
|
||||||
#@exception
|
|
||||||
#@note
|
|
||||||
#@todo
|
|
||||||
#@version 0.9 - Primera versión para OpenGnSys
|
|
||||||
#@author Antonio J. Doblas Viso, Universidad de Málaga
|
|
||||||
#@date 2010/02/15
|
|
||||||
#*/ ##
|
|
||||||
|
|
||||||
function ogClientUnmount ()
|
|
||||||
{
|
|
||||||
cd /tmp
|
|
||||||
echo "desmontando cliente espere"
|
|
||||||
sleep 5
|
|
||||||
mount | grep $OGCLIENTMOUNT/dev > /dev/null && umount $OGCLIENTMOUNT/dev || ogClientUnmount
|
|
||||||
mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null && umount $OGCLIENTMOUNT/dev/pts || ogClientUnmount
|
|
||||||
mount | grep $OGCLIENTMOUNT/proc > /dev/null && umount $OGCLIENTMOUNT/proc || ogClientUnmount
|
|
||||||
mount | grep $OGCLIENTMOUNT/sys > /dev/null && umount $OGCLIENTMOUNT/sys || ogClientUnmount
|
|
||||||
mount | grep $OGCLIENTMOUNT/tmp > /dev/null && umount $OGCLIENTMOUNT/tmp || ogClientUnmount
|
|
||||||
mount | grep $OGCLIENTMOUNT > /dev/null && umount $OGCLIENTMOUNT || ogClientUnmount
|
|
||||||
#-d -f -l
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,121 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#@file boottoolsgenerator.sh
|
|
||||||
#@brief Script generación del sistema opertativo cliente OpenGnsys
|
|
||||||
#@warning
|
|
||||||
#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2010/05/24
|
|
||||||
#@version 1.0 - Compatibilidad OpengGnsys X.
|
|
||||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
|
||||||
#@date 2011/08/03
|
|
||||||
#*/
|
|
||||||
|
|
||||||
|
|
||||||
BRANCH="branches/master"
|
|
||||||
svn export --force https://github.com/opengnsys/OpenGnsys/$BRANCH/client /tmp/opengnsys_installer/opengnsys/client || exit 1
|
|
||||||
|
|
||||||
#Variables
|
|
||||||
TYPECLIENT="${1:-host}"
|
|
||||||
WORKDIR=/tmp/opengnsys_installer
|
|
||||||
INSTALL_TARGET=/opt/opengnsys
|
|
||||||
PROGRAMDIR=$(readlink -e $(dirname "$0"))
|
|
||||||
|
|
||||||
# Solo ejecutable por usuario root
|
|
||||||
if [ "$(whoami)" != 'root' ]
|
|
||||||
then
|
|
||||||
echo "ERROR: this program must run under root privileges!!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cambiar a directorio temporal.
|
|
||||||
cd /tmp
|
|
||||||
|
|
||||||
for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
|
|
||||||
for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
|
|
||||||
for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
|
|
||||||
|
|
||||||
|
|
||||||
#funciones especificas del cliente.
|
|
||||||
source $PROGRAMDIR/boottoolsfunctions.lib
|
|
||||||
|
|
||||||
####################################################################3
|
|
||||||
echo "FASE 1 - Asignación de variables"
|
|
||||||
#obtenemos las variables necesarias y la información del host.
|
|
||||||
btogGetVar
|
|
||||||
echoAndLog "OpenGnsys CLIENT installation begins at $(date)"
|
|
||||||
btogGetOsInfo $TYPECLIENT
|
|
||||||
##########################################################################
|
|
||||||
echo "FASE 2 - Instalación de software adicional."
|
|
||||||
#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
|
|
||||||
apt-get update
|
|
||||||
[ -n "$(apt-cache search gpxe)" ] && PXEPKG="gpxe"
|
|
||||||
[ -n "$(apt-cache search ipxe)" ] && PXEPKG="ipxe"
|
|
||||||
apt-get -y install debootstrap subversion schroot squashfs-tools syslinux genisoimage $PXEPKG qemu qemu-utils lsof
|
|
||||||
###################################################################3
|
|
||||||
echo "FASE 3 - Creación del Sistema raiz RootFS (Segundo Sistema archivos (img)) "
|
|
||||||
echo "Fase 3.1 Generar y formatear el disco virtual. Generar el dispositivo loop."
|
|
||||||
file $BTROOTFSIMG | grep "partition 1: ID=0x83"
|
|
||||||
if [ $? == 1 ]
|
|
||||||
then
|
|
||||||
btogSetFsVirtual || exit 2
|
|
||||||
fi
|
|
||||||
echo "Fase 3.2 Generar sistema de archivos con debootstrap"
|
|
||||||
schroot -p -c IMGogclient -- touch /tmp/ogclientOK
|
|
||||||
if [ -f /tmp/ogclientOK ]
|
|
||||||
then
|
|
||||||
rm /tmp/ogclientOK
|
|
||||||
else
|
|
||||||
btogSetFsBase || exit 3
|
|
||||||
fi
|
|
||||||
###################################################################3
|
|
||||||
echo "FASE 4 - Configurar acceso schroot al Segundo Sistema de archivos (img)"
|
|
||||||
cat /etc/schroot/schroot.conf | grep $BTROOTFSIMG || btogSetFsAccess
|
|
||||||
###########################################################################
|
|
||||||
echo "FASE 5 - Incorporando ficheros OpenGnsys al sistema raíz rootfs "
|
|
||||||
cp -a ${BTDIR}/includes/usr/bin/* /tmp
|
|
||||||
chmod +x /tmp/boot-tools/*.sh
|
|
||||||
# Incluir revisión.
|
|
||||||
sed -i "1 s/$/ $GITRELEASE ($OSRELEASE)/" ${BTDIR}/includes/etc/initramfs-tools/scripts/VERSION.txt
|
|
||||||
# En Ubuntu 13.04+ es necesario matar proceso de "udev" antes de desmontar.
|
|
||||||
umount $BTROOTFSMNT 2>/dev/null || (kill -9 $(lsof -t $BTROOTFSMNT); umount $BTROOTFSMNT) 2>/dev/null
|
|
||||||
schroot -p -c IMGogclient -- /tmp/boot-tools/boottoolsFsOpengnsys.sh
|
|
||||||
############################################################################################
|
|
||||||
echo "FASE 6 - Instalar software"
|
|
||||||
echo "Fase 6.1 instalar paquetes deb con apt-get"
|
|
||||||
schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareInstall.sh
|
|
||||||
echo "Fase 6.2 compilar software."
|
|
||||||
cd /
|
|
||||||
schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareCompile.sh
|
|
||||||
cd -
|
|
||||||
|
|
||||||
echo "FASE 7 - Personalizar el sistema creado"
|
|
||||||
echo "Fase 7.1 Incorporar la clave publica del servidor"
|
|
||||||
cd /
|
|
||||||
ssh-keygen -q -f /root/.ssh/id_rsa -N ""
|
|
||||||
cp /root/.ssh/id_rsa.pub /tmp
|
|
||||||
schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshServer.sh
|
|
||||||
cd -
|
|
||||||
echo "Fase 7.2. Incorpoar la clave publica del propio cliente"
|
|
||||||
schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshClient.sh
|
|
||||||
|
|
||||||
echo "Fase 7.3. Configurando las locales"
|
|
||||||
schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsFsLocales.sh
|
|
||||||
|
|
||||||
|
|
||||||
for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
|
|
||||||
for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
|
|
||||||
for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done
|
|
||||||
|
|
||||||
#########################################################################
|
|
||||||
echo "FASE 8 - Generar distribucion"
|
|
||||||
echo "Fase 8.1 Generar el initrd"
|
|
||||||
btogFsInitrd
|
|
||||||
echo "Fase 8.2 Generar fichero sqfs a partir del fichero img"
|
|
||||||
btogFsSqfs
|
|
||||||
umount $BTROOTFSMNT 2>/dev/null
|
|
||||||
echo "Fase 8.3 Generar la ISO"
|
|
||||||
btogIsoGenerator
|
|
||||||
######################################################################3
|
|
||||||
########################################################################
|
|
||||||
echoAndLog "OpenGnsys installation finished at $(date)"
|
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import shutil
|
||||||
|
import os
|
||||||
|
import glob
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from boottools import utils, apt
|
||||||
|
|
||||||
|
def _oghook_deactivate():
|
||||||
|
#Desactivamos el hook del oginitrd.img para evitar problemas, al final de este escripts se activará
|
||||||
|
os.rename ('/etc/initramfs-tools/hooks/oghooks', '/etc/initramfs-tools/oghooks')
|
||||||
|
|
||||||
|
def _oghook_activate():
|
||||||
|
#Activamos el hook del oginitrd.img
|
||||||
|
os.rename ('/etc/initramfs-tools/oghooks', '/etc/initramfs-tools/hooks/oghooks')
|
||||||
|
|
||||||
|
def boottoolsSoftwareInstall (osarch, osrelease):
|
||||||
|
os.environ['LANGUAGE'] = 'C'
|
||||||
|
os.environ['LC_ALL'] = 'C'
|
||||||
|
os.environ['LANG'] = 'C'
|
||||||
|
os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
|
||||||
|
|
||||||
|
stdout, _ = utils.run (['dpkg-divert', '--list'])
|
||||||
|
if not re.findall (r'local diversion of /sbin/initctl to /sbin/initctl.distrib', stdout):
|
||||||
|
utils.run (['dpkg-divert', '--local', '--rename', '--add', '/sbin/initctl'])
|
||||||
|
os.symlink ('/bin/true', '/sbin/initctl')
|
||||||
|
|
||||||
|
pkgs32 = []
|
||||||
|
if 'i386' != osarch:
|
||||||
|
utils.run (['dpkg', '--add-architecture', 'i386'])
|
||||||
|
pkgs32 = 'lib32gcc-s1 lib32stdc++6 lib32z1 libc6-i386'.split (' ') ## nserrano: he cambiado lib32gcc1 por lib32gcc-s1 pero como queramos crear un oglive viejo, esto va a petar
|
||||||
|
|
||||||
|
_oghook_deactivate()
|
||||||
|
|
||||||
|
print ('boottoolsSoftwareInstall: debconf-set-selections', file=sys.stderr)
|
||||||
|
subprocess.run (['debconf-set-selections'], input=debconf_settings, text=True)
|
||||||
|
utils.run (['dpkg-reconfigure', '--frontend', 'noninteractive', 'console-setup', 'locales']) ## XXX: despues de esto, debconf-get-selections devuelve los valores antiguos, no se por que...
|
||||||
|
|
||||||
|
pkgs = []
|
||||||
|
for section in config.options('Packages'):
|
||||||
|
pkgs += re.split (r'[ \n]', config['Packages'].get(section).strip())
|
||||||
|
|
||||||
|
pkgs = [f'linux-image-{osrelease}', f'linux-headers-{osrelease}', f'linux-modules-{osrelease}', f'linux-modules-extra-{osrelease}', 'dkms', 'shim-signed', 'openssl', 'sshfs', 'kexec-tools'] + pkgs32 + pkgs
|
||||||
|
print (f'boottoolsSoftwareInstall: installing packages: {str(pkgs)}', file=sys.stderr)
|
||||||
|
apt.install (pkgs, opts={'DPkg::Options::': '--force-confdef'}) ## --force-confdef is required to avoid an interactive question regarding /etc/ssh/ssh_config
|
||||||
|
|
||||||
|
# Instalar módulos que algunos paquetes puedan tener pendientes de compilar.
|
||||||
|
print ('boottoolsSoftwareInstall: dkms', file=sys.stderr)
|
||||||
|
stdout, _ = utils.run (['dkms', 'status'])
|
||||||
|
for l in stdout.strip().split ('\n'):
|
||||||
|
if not l: continue
|
||||||
|
#print (f'l "{l}"')
|
||||||
|
mod, vers, status = l.split (',')
|
||||||
|
if 'added' in status:
|
||||||
|
print (f'dkms installing {mod} {vers}')
|
||||||
|
utils.run (['dkms', 'install', '-m', mod.strip(), '-v', vers.strip()])
|
||||||
|
|
||||||
|
_oghook_activate()
|
||||||
|
apt.clean()
|
||||||
|
apt.autoremove()
|
||||||
|
|
||||||
|
def boottoolsSoftwareCompile():
|
||||||
|
env_language = os.environ['LANGUAGE']
|
||||||
|
env_lc_all = os.environ['LC_ALL']
|
||||||
|
env_lang = os.environ['LANG']
|
||||||
|
os.environ['LANGUAGE'] = os.environ['LC_ALL'] = os.environ['LANG'] = 'C'
|
||||||
|
os.chdir ('/tmp')
|
||||||
|
|
||||||
|
print ('boottoolsSoftwareCompile: ms-sys', file=sys.stderr)
|
||||||
|
try: utils.run (['which', 'ms-sys'])
|
||||||
|
except:
|
||||||
|
utils.run (['wget', '--quiet', 'https://sourceforge.net/projects/ms-sys/files/latest/download', '-O', 'ms-sys.tar.gz'])
|
||||||
|
utils.run (['tar', '-xpzf', 'ms-sys.tar.gz'])
|
||||||
|
mssys_dir = subprocess.run (['tar tzf ms-sys.tar.gz |head -n 1'], shell=True, capture_output=True, text=True).stdout.strip()
|
||||||
|
print (f'mssys_dir "{mssys_dir}"')
|
||||||
|
os.chdir (mssys_dir)
|
||||||
|
utils.run (['make', 'install'])
|
||||||
|
os.chdir ('..')
|
||||||
|
|
||||||
|
print ('boottoolsSoftwareCompile: spartlnx', file=sys.stderr)
|
||||||
|
try: utils.run (['which', 'spartl64.run'])
|
||||||
|
except:
|
||||||
|
utils.run (['wget', '--quiet', 'http://damien.guibouret.free.fr/savepart.zip'])
|
||||||
|
utils.run (['unzip', '-o', 'savepart.zip', '-d', '/sbin/', 'spartl64.run'])
|
||||||
|
utils.run (['mkdir', '/usr/share/doc/spartlnx'])
|
||||||
|
utils.run (['unzip', '-j', '-o', 'savepart.zip', '-d', '/usr/share/doc/spartlnx/', 'doc/en/*'])
|
||||||
|
|
||||||
|
if not os.path.exists ('python-libfdisk'):
|
||||||
|
print ('boottoolsSoftwareCompile: python-libfdisk', file=sys.stderr)
|
||||||
|
apt.install (['python3-psutil', 'python3-dev', 'libfdisk-dev', 'python3-setuptools'])
|
||||||
|
utils.run (['git', 'clone', 'git://git.48k.eu/python-libfdisk'])
|
||||||
|
os.chdir ('python-libfdisk')
|
||||||
|
utils.run (['python3', 'setup.py', 'install'])
|
||||||
|
os.chdir ('..')
|
||||||
|
apt.remove (['python3-dev', 'python3-setuptools'])
|
||||||
|
|
||||||
|
os.environ['LANGUAGE'] = env_language
|
||||||
|
os.environ['LC_ALL'] = env_lc_all
|
||||||
|
os.environ['LANG'] = env_lang
|
||||||
|
|
||||||
|
def boottoolsInitrdGenerate (osrelease):
|
||||||
|
print ('boottoolsInitrdGenerate', file=sys.stderr)
|
||||||
|
for f in glob.glob ('/usr/lib/initramfs-tools/bin/*'):
|
||||||
|
os.unlink (f)
|
||||||
|
shutil.copy ('/bin/busybox', '/usr/lib/initramfs-tools/bin')
|
||||||
|
|
||||||
|
os.chdir ('/tmp')
|
||||||
|
utils.run (['mkinitramfs', '-o', f'/tmp/initrd.img-{osrelease}', osrelease])
|
||||||
|
shutil.copy (f'/boot/vmlinuz-{osrelease}', '/tmp/')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument ('--osarch', help='OS architecture', action='store', required=True)
|
||||||
|
parser.add_argument ('--osrelease', help='OS release', action='store', required=True)
|
||||||
|
parser.add_argument ('--config', help='Path to configuration file', action='store')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
config = utils.read_config (args.config or 'mkoglive.cfg')
|
||||||
|
if config is None:
|
||||||
|
sys.exit (1)
|
||||||
|
debconf_settings = config['General'].get ('debconf_settings')
|
||||||
|
|
||||||
|
boottoolsSoftwareInstall (args.osarch, args.osrelease)
|
||||||
|
boottoolsSoftwareCompile()
|
||||||
|
boottoolsInitrdGenerate (args.osrelease)
|
|
@ -55,6 +55,6 @@ deb http://free.nchc.org.tw/ubuntu OSCODENAME-security main restricted universe
|
||||||
#deb http://ppa.launchpad.net/randomaction/ppa/ubuntu OSCODENAME main
|
#deb http://ppa.launchpad.net/randomaction/ppa/ubuntu OSCODENAME main
|
||||||
#deb-src http://ppa.launchpad.net/randomaction/ppa/ubuntu OSCODENAME main
|
#deb-src http://ppa.launchpad.net/randomaction/ppa/ubuntu OSCODENAME main
|
||||||
# Ubuntu-ZFS
|
# Ubuntu-ZFS
|
||||||
deb http://ppa.launchpad.net/zfs-native/stable/ubuntu OSCODENAME main
|
#deb http://ppa.launchpad.net/zfs-native/stable/ubuntu OSCODENAME main
|
||||||
deb-src http://ppa.launchpad.net/zfs-native/stable/ubuntu OSCODENAME main
|
#deb-src http://ppa.launchpad.net/zfs-native/stable/ubuntu OSCODENAME main
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,6 @@ Protocol 2
|
||||||
# HostKeys for protocol version 2
|
# HostKeys for protocol version 2
|
||||||
HostKey /etc/ssh/ssh_host_rsa_key
|
HostKey /etc/ssh/ssh_host_rsa_key
|
||||||
HostKey /etc/ssh/ssh_host_dsa_key
|
HostKey /etc/ssh/ssh_host_dsa_key
|
||||||
#Privilege Separation is turned on for security
|
|
||||||
UsePrivilegeSeparation no
|
|
||||||
|
|
||||||
# Lifetime and size of ephemeral version 1 server key
|
|
||||||
KeyRegenerationInterval 3600
|
|
||||||
ServerKeyBits 768
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
SyslogFacility AUTH
|
SyslogFacility AUTH
|
||||||
|
@ -26,14 +20,11 @@ LoginGraceTime 120
|
||||||
PermitRootLogin yes
|
PermitRootLogin yes
|
||||||
StrictModes yes
|
StrictModes yes
|
||||||
|
|
||||||
RSAAuthentication yes
|
|
||||||
PubkeyAuthentication yes
|
PubkeyAuthentication yes
|
||||||
#AuthorizedKeysFile %h/.ssh/authorized_keys
|
#AuthorizedKeysFile %h/.ssh/authorized_keys
|
||||||
|
|
||||||
# Don't read the user's ~/.rhosts and ~/.shosts files
|
# Don't read the user's ~/.rhosts and ~/.shosts files
|
||||||
IgnoreRhosts yes
|
IgnoreRhosts yes
|
||||||
# For this to work you will also need host keys in /etc/ssh_known_hosts
|
|
||||||
RhostsRSAAuthentication no
|
|
||||||
# similar for protocol version 2
|
# similar for protocol version 2
|
||||||
HostbasedAuthentication no
|
HostbasedAuthentication no
|
||||||
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
|
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null;
|
|
||||||
|
|
||||||
#plymouth
|
|
||||||
apt-get -y install plymouth plymouth-theme-script
|
|
||||||
|
|
||||||
|
|
||||||
#plymoutyh
|
|
||||||
update-alternatives --install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/opengnsys/opengnsys.plymouth 100
|
|
||||||
update-alternatives --set default.plymouth /lib/plymouth/themes/opengnsys/opengnsys.plymouth
|
|
||||||
|
|
||||||
mkdir -p /etc/initramfs-tools/conf.d
|
|
||||||
echo "FRAMEBUFFER=y" > /etc/initramfs-tools/conf.d/splash
|
|
||||||
|
|
||||||
history -c
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
cat << EOT | debconf-set-selections --
|
|
||||||
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
|
|
||||||
EOT
|
|
||||||
dpkg-reconfigure console-setup locales
|
|
||||||
|
|
||||||
history -c
|
|
|
@ -1,74 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
VERSIONBOOTTOOLS="ogLive"
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
OGCLIENTMOUNT=""
|
|
||||||
|
|
||||||
OGCLIENTCFG=${OGCLIENTCFG:-/tmp/ogclient.cfg}
|
|
||||||
[ -f $OGCLIENTCFG ] && source $OGCLIENTCFG
|
|
||||||
OSDISTRIB=${OSDISTRIB:-$(lsb_release -is)}
|
|
||||||
OSCODENAME=${OSCODENAME:-$(lsb_release -cs)}
|
|
||||||
OSRELEASE=${OSRELEASE:-$(uname -r)}
|
|
||||||
OSARCH=${OSARCH:-$(dpkg --print-architecture)}
|
|
||||||
OSHTTP=${OSHTTP:-"http://es.archive.ubuntu.com/ubuntu/"}
|
|
||||||
|
|
||||||
echo "$OSDISTRIB:$OSCODENAME:$OSRELEASE:$OSARCH:$OSHTTP"
|
|
||||||
|
|
||||||
|
|
||||||
LERROR=TRUE
|
|
||||||
|
|
||||||
echo "$FUNCNAME: Iniciando la personalización con datos del repositorio"
|
|
||||||
|
|
||||||
# parseamos el apt.source de la distribución (en minúsculas)
|
|
||||||
sed -e "s/OSCODENAME/$OSCODENAME/g" ${SVNCLIENTDIR}/includes/etc/apt/sources.list.${OSDISTRIB,,} > ${SVNCLIENTDIR}/includes/etc/apt/sources.list
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
echo "$FUNCNAME(): Parsing apt.sources : ERROR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#damos permiso al directorio de scripts
|
|
||||||
chmod -R 775 ${SVNCLIENTDIR}/includes/usr/bin/*
|
|
||||||
|
|
||||||
# los copiamos
|
|
||||||
cp -av ${SVNCLIENTDIR}/includes/* ${OGCLIENTMOUNT}/
|
|
||||||
mkdir -p ${OGCLIENTMOUNT}/opt/opengnsys/
|
|
||||||
cp -av ${SVNCLIENTSTRUCTURE}/* ${OGCLIENTMOUNT}/opt/opengnsys/
|
|
||||||
mkdir -p ${OGCLIENTMOUNT}/opt/opengnsys/lib/engine/bin/
|
|
||||||
cp -av ${SVNCLIENTENGINE}/* ${OGCLIENTMOUNT}/opt/opengnsys/lib/engine/bin/
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
echo "$FUNCNAME(): Copying client data : ERROR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Si no existe, copiar pci.ids.
|
|
||||||
[ -f $OGCLIENTMOUNT/etc/pci.ids ] || cp -va ${SVNCLIENTSTRUCTURE}/lib/pci.ids $OGCLIENTMOUNT/etc
|
|
||||||
|
|
||||||
# Dependencias Qt para el Browser.
|
|
||||||
mkdir -p $OGCLIENTMOUNT/usr/local/{etc,lib,plugins}
|
|
||||||
cp -av ${SVNCLIENTSTRUCTURE}/lib/qtlib/* $OGCLIENTMOUNT/usr/local/lib
|
|
||||||
cp -av ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/lib
|
|
||||||
cp -av ${SVNCLIENTSTRUCTURE}/lib/qtplugins/* $OGCLIENTMOUNT/usr/local/plugins
|
|
||||||
cp -av ${SVNCLIENTSTRUCTURE}/etc/*.qmap $OGCLIENTMOUNT/usr/local/etc
|
|
||||||
|
|
||||||
# Browser y ogAdmClient.
|
|
||||||
[ -x ${SVNCLIENTSTRUCTURE}/bin/browser ] && cp -av ${SVNCLIENTSTRUCTURE}/bin/browser $OGCLIENTMOUNT/bin
|
|
||||||
[ -x ${SVNCLIENTSTRUCTURE}/bin/ogAdmClient ] && cp -av ${SVNCLIENTSTRUCTURE}/bin/ogAdmClient $OGCLIENTMOUNT/bin
|
|
||||||
|
|
||||||
# El fichero de configuración debe sustituir a los 2 ficheros (borrar las 2 líneas).
|
|
||||||
echo "${VERSIONBOOTTOOLS}-${OSCODENAME}-${OSRELEASE}-${GITRELEASE}" > /$NAMEISOCLIENTFILE
|
|
||||||
echo "${VERSIONBOOTTOOLS}-${OSCODENAME}-${GITRELEASE}" > $NAMEHOSTCLIENTFILE
|
|
||||||
|
|
||||||
|
|
||||||
history -c
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
history -c
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
OGCLIENTCFG=${OGCLIENTCFG:-/tmp/ogclient.cfg}
|
|
||||||
[ -f $OGCLIENTCFG ] && source $OGCLIENTCFG
|
|
||||||
OSRELEASE=${OSRELEASE:-$(uname -r)}
|
|
||||||
|
|
||||||
rm -f /usr/lib/initramfs-tools/bin/*
|
|
||||||
cp /bin/busybox /usr/lib/initramfs-tools/bin
|
|
||||||
cd /tmp
|
|
||||||
mkinitramfs -o /tmp/initrd.img-$OSRELEASE -v $OSRELEASE
|
|
||||||
cp -v /boot/vmlinuz-$OSRELEASE /tmp
|
|
||||||
|
|
||||||
history -c
|
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
################################################################
|
|
||||||
##################### SOFTWARE #####################
|
|
||||||
################################################################
|
|
||||||
OLDLANGUAGE=$LANGUAGE
|
|
||||||
OLDLC_ALL=$LC_ALL
|
|
||||||
OLDLANG=$LANG
|
|
||||||
export LANGUAGE=C
|
|
||||||
export LC_ALL=C
|
|
||||||
export LANG=C
|
|
||||||
|
|
||||||
|
|
||||||
source /opt/opengnsys/lib/engine/bin/ToolsGNU.c &>/dev/null
|
|
||||||
pushd /tmp
|
|
||||||
|
|
||||||
echo "ms-sys"
|
|
||||||
which ms-sys || (wget https://sourceforge.net/projects/ms-sys/files/latest/download -O ms-sys.tar.gz; tar xpvzf ms-sys.tar.gz; cd $(tar tzf ms-sys.tar.gz|head -1); make install; cd ..)
|
|
||||||
|
|
||||||
echo "spartlnx"
|
|
||||||
which spartlnx.run || $(wget http://damien.guibouret.free.fr/savepart.zip &>/dev/null; unzip -o savepart.zip -d /sbin/)
|
|
||||||
|
|
||||||
echo "python-libfdisk"
|
|
||||||
apt-get -y install python3-psutil python3-dev libfdisk-dev python3-setuptools
|
|
||||||
git clone git://git.48k.eu/python-libfdisk
|
|
||||||
pushd python-libfdisk
|
|
||||||
python3 setup.py install
|
|
||||||
popd
|
|
||||||
apt-get -y remove python3-dev python3-setuptools
|
|
||||||
|
|
||||||
popd
|
|
||||||
export LANGUAGE=$OLDLANGUAGE
|
|
||||||
export LC_ALL=$OLDLC_ALL
|
|
||||||
export LANG=$OLDLANG
|
|
||||||
|
|
||||||
history -c
|
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Script de instalación de paquetes de software.
|
|
||||||
|
|
||||||
export LANGUAGE=C
|
|
||||||
export LC_ALL=C
|
|
||||||
export LANG=C
|
|
||||||
#LOG_FILE=/tmp/boot-tools-software.txt
|
|
||||||
|
|
||||||
#ADV
|
|
||||||
#Desactivamos upstart
|
|
||||||
dpkg-divert --local --rename --add /sbin/initctl
|
|
||||||
ln -s /bin/true /sbin/initctl
|
|
||||||
#TEST desactivamos upstart
|
|
||||||
#apt-get update; apt-get install --no-install-recommends dbus; dbus-uuidgen > /var/lib/dbus/machine-id; dpkg-divert --local --rename --add /sbin/initctl; ln -s /bin/true /sbin/initctl
|
|
||||||
|
|
||||||
#cp /tmp/sources.list /etc/apt/sources.list
|
|
||||||
#Limpiamos y actualizamos los repositorios apt (incluir siempre paquetes de 32 bits)
|
|
||||||
apt-get clean
|
|
||||||
OSARCH=${OSARCH:-$(dpkg --print-architecture)}
|
|
||||||
if [ "$OSARCH" != "i386" ]; then
|
|
||||||
dpkg --add-architecture i386
|
|
||||||
PKGS32="lib32gcc1 lib32stdc++6 lib32z1 libc6-i386"
|
|
||||||
fi
|
|
||||||
apt-get update
|
|
||||||
apt-get upgrade -y
|
|
||||||
|
|
||||||
#Desactivamos el hook del oginitrd.img para evitar problemas, al final de este escripts se activará
|
|
||||||
mv /etc/initramfs-tools/hooks/oghooks /etc/initramfs-tools/
|
|
||||||
|
|
||||||
# Preparamos el mtab necesario para la instalacion correcta de paquetes.
|
|
||||||
echo "/dev/sda1 / ext4 rw,errors=remount-ro 0 0" > /etc/mtab
|
|
||||||
|
|
||||||
# Instalamos el kernel.
|
|
||||||
# Deteccion de la versión y kernel a usar
|
|
||||||
OGCLIENTCFG=${OGCLIENTCFG:-/tmp/ogclient.cfg}
|
|
||||||
[ -f $OGCLIENTCFG ] && source $OGCLIENTCFG
|
|
||||||
OSRELEASE=${OSRELEASE:-$(uname -r)}
|
|
||||||
# Instalar Kernel firmado del repositorio de paquetes.
|
|
||||||
apt-get -y install linux-image-${OSRELEASE} linux-headers-${OSRELEASE} dkms shim-signed
|
|
||||||
apt-get -y install linux-modules-${OSRELEASE} linux-modules-extra-${OSRELEASE} 2>/dev/null
|
|
||||||
|
|
||||||
# Valores para paquetes interactivos.
|
|
||||||
cat << EOT | debconf-set-selections --
|
|
||||||
kexec-tools kexec-tools/load_kexec boolean true
|
|
||||||
openssh-server openssh-server/permit-root-login boolean true
|
|
||||||
refind refind/install_to_esp boolean false
|
|
||||||
EOT
|
|
||||||
apt-get -y install sshfs kexec-tools $PKGS32
|
|
||||||
|
|
||||||
#comenzamos con la instalación de los paquetes a instalar.
|
|
||||||
for group in `find /usr/bin/boot-tools/listpackages/ -name sw.*`
|
|
||||||
do
|
|
||||||
echo "Instalando el grupo de paquetes almacenados en $group"
|
|
||||||
for package in ` awk /^install/'{print $2}' $group `
|
|
||||||
do
|
|
||||||
echo -n $package
|
|
||||||
apt-get -y install $package &>/dev/null
|
|
||||||
RETVAL=$?
|
|
||||||
if [ $RETVAL == 0 ]
|
|
||||||
then
|
|
||||||
echo " : OK - Paquete instalado correctamente (codigo interno de apt-get $RETVAL)"
|
|
||||||
else
|
|
||||||
echo " : Error Paquete $package del grupo $group (codigo interno de apt-get $RETVAL) "
|
|
||||||
echo "Pulse [Intro] para continuar"
|
|
||||||
read
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
# Instalar módulos que algunos paquetes puedan tener pendientes de compilar.
|
|
||||||
echo "Instalando módulos adicionales con DKMS"
|
|
||||||
while read -e mod vers; do
|
|
||||||
echo -n "Intalando módulo $mod v$vers"
|
|
||||||
dkms install -m $mod -v $vers &>/dev/null
|
|
||||||
RETVAL=$?
|
|
||||||
if [ $RETVAL == 0 ]; then
|
|
||||||
echo " : OK - Módulo instalado correctamente (codigo interno de dkms $RETVAL)"
|
|
||||||
else
|
|
||||||
echo " : Error módulo $mod (codigo interno de dkms $RETVAL) "
|
|
||||||
echo "Pulse [Intro] para continuar"
|
|
||||||
read
|
|
||||||
fi
|
|
||||||
done < <(dkms status 2>/dev/null | awk -F, '$3~/added/ {print $1,$2}')
|
|
||||||
|
|
||||||
#Activamos el hook del oginitrd.img
|
|
||||||
mv /etc/initramfs-tools/oghooks /etc/initramfs-tools/hooks/
|
|
||||||
|
|
||||||
# Dejamos el mtab como al principio
|
|
||||||
echo " " > /etc/mtab
|
|
||||||
|
|
||||||
|
|
||||||
#ADV
|
|
||||||
#TEST
|
|
||||||
#apt-get install localepurge
|
|
||||||
#localepurge
|
|
||||||
#rm /var/lib/dbus/machine-id; rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl;
|
|
||||||
#FIN ADV
|
|
||||||
|
|
||||||
apt-get clean
|
|
||||||
apt-get autoclean
|
|
||||||
apt-get autoremove
|
|
||||||
|
|
||||||
history -c
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
export LANGUAGE=C
|
|
||||||
export LC_ALL=C
|
|
||||||
export LANG=C
|
|
||||||
|
|
||||||
apt-get clean
|
|
||||||
apt-get -y update
|
|
||||||
|
|
||||||
apt-get -y --force-yes install xorg-dev xorg lxde roxterm
|
|
||||||
|
|
||||||
apt-get clean
|
|
||||||
|
|
||||||
history -c
|
|
|
@ -1,25 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
echo "comprobando directorio .ssh del root"
|
|
||||||
if [ ! -d /root/.ssh ]
|
|
||||||
then
|
|
||||||
echo "creando directorio .ssh 600"
|
|
||||||
mkdir -p /root/.ssh
|
|
||||||
chmod 700 /root/.ssh
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
echo "comprobando el fichero authorized_keys .ssh del root"
|
|
||||||
if [ ! -f /root/.ssh/authorized_keys ]
|
|
||||||
then
|
|
||||||
echo "creando el fichero authorized_keys"
|
|
||||||
touch /root/.ssh/authorized_keys
|
|
||||||
chmod 600 /root/.ssh/authorized_keys
|
|
||||||
fi
|
|
||||||
|
|
||||||
ssh-keygen -q -f /root/.ssh/id_rsa -N ""
|
|
||||||
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
|
|
||||||
|
|
||||||
## TODO: exportamos la publica a los repos
|
|
||||||
cp /root/.ssh/id_rsa.pub /tmp/rsa.ogclient.pub
|
|
||||||
|
|
||||||
history -c
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
echo "comprobando directorio .ssh del root"
|
|
||||||
if [ ! -d /root/.ssh ]
|
|
||||||
then
|
|
||||||
echo "creando directorio .ssh 600"
|
|
||||||
mkdir -p /root/.ssh
|
|
||||||
chmod 700 /root/.ssh
|
|
||||||
fi
|
|
||||||
echo "creando el fichero authorized_keys"
|
|
||||||
touch /root/.ssh/authorized_keys
|
|
||||||
chmod 600 /root/.ssh/authorized_keys
|
|
||||||
|
|
||||||
echo "importando la clave publica del servidor OG"
|
|
||||||
cat /tmp/id_rsa.pub
|
|
||||||
|
|
||||||
[ -f /tmp/id_rsa.pub ] && cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys || echo "no key publica og"
|
|
||||||
|
|
||||||
history -c
|
|
|
@ -1,12 +0,0 @@
|
||||||
#sw.X
|
|
||||||
#+300M
|
|
||||||
#install xorg-dev
|
|
||||||
#install xorg
|
|
||||||
#install lxde
|
|
||||||
#+80M roxterm y gparted
|
|
||||||
#install roxterm
|
|
||||||
#install gparted
|
|
||||||
#xvesa en compilacion
|
|
||||||
#install openbox
|
|
||||||
#install midori
|
|
||||||
install v86d # VESA Kernel 3.7+
|
|
|
@ -1,25 +0,0 @@
|
||||||
#Format install paquete
|
|
||||||
install dialog
|
|
||||||
install man-db
|
|
||||||
install fbset
|
|
||||||
install gdebi-core
|
|
||||||
install bash-static
|
|
||||||
install busybox-static
|
|
||||||
#install console-data # ogLive anterior a Ubuntu 20.04
|
|
||||||
install locales
|
|
||||||
install lshw
|
|
||||||
install gawk
|
|
||||||
#install subversion # ogLive anterior a Ubuntu 18.04
|
|
||||||
install git # ogLive a partir de Ubuntu 18.04
|
|
||||||
install python-openssl
|
|
||||||
install python
|
|
||||||
#install php5-cli # ogLive anterior a Ubuntu 16.04
|
|
||||||
install php-cli # ogLive a partir de Ubuntu 16.04
|
|
||||||
install dmidecode
|
|
||||||
#install realpath # ogLive hasta Ubuntu 16.04
|
|
||||||
install rpm
|
|
||||||
#install zypper # PROBAR
|
|
||||||
install sqlite3
|
|
||||||
install os-prober
|
|
||||||
install moreutils
|
|
||||||
install jq
|
|
|
@ -1,17 +0,0 @@
|
||||||
#sw.cloning
|
|
||||||
install fsarchiver
|
|
||||||
install pv
|
|
||||||
install pxe-kexec
|
|
||||||
install mbuffer
|
|
||||||
install parted
|
|
||||||
install gdisk
|
|
||||||
install chntpw
|
|
||||||
install clonezilla
|
|
||||||
install registry-tools
|
|
||||||
install reglookup
|
|
||||||
install libparse-win32registry-perl
|
|
||||||
install libwin-hivex-perl
|
|
||||||
install grokevt
|
|
||||||
install libhivex0
|
|
||||||
install libhivex-bin
|
|
||||||
install rsync
|
|
|
@ -1,11 +0,0 @@
|
||||||
install build-essential
|
|
||||||
#install libattr* # Satura el tamaño del archivo en Ubuntu 15.04
|
|
||||||
install libattr1
|
|
||||||
install libattr1-dev
|
|
||||||
install uuid-dev
|
|
||||||
install attr
|
|
||||||
install make
|
|
||||||
install m4
|
|
||||||
install gettext
|
|
||||||
install libmhash-dev
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#sw.compressor
|
|
||||||
install lzma
|
|
||||||
install zip
|
|
||||||
install unzip
|
|
||||||
install gzip
|
|
||||||
install lzop
|
|
||||||
install pigz
|
|
||||||
install pbzip2
|
|
||||||
install lbzip2
|
|
||||||
install rzip
|
|
||||||
install p7zip-full
|
|
|
@ -1,32 +0,0 @@
|
||||||
#sw.filesystem.local
|
|
||||||
install squashfs-tools
|
|
||||||
install unionfs-fuse
|
|
||||||
#install drbl-ntfsprogs # Eliminado
|
|
||||||
install ntfs-3g
|
|
||||||
#install ntfs-config # ogLive anterior a Ubuntu 20.04
|
|
||||||
install dosfstools
|
|
||||||
install fatresize
|
|
||||||
install exfat-utils
|
|
||||||
install dmraid
|
|
||||||
install dmsetup
|
|
||||||
install lvm2
|
|
||||||
install e2fsprogs
|
|
||||||
#install btrfs-tools # ogLive anterior a Ubuntu 20.04
|
|
||||||
install btrfs-progs # ogLive a partir de Ubuntu 20.04
|
|
||||||
install jfsutils
|
|
||||||
install reiserfsprogs
|
|
||||||
install reiser4progs
|
|
||||||
install xfsprogs
|
|
||||||
install mhddfs
|
|
||||||
install hfsplus
|
|
||||||
install hfsprogs
|
|
||||||
install hfsutils
|
|
||||||
install nilfs-tools
|
|
||||||
install vmfs-tools
|
|
||||||
#install ufsutils # ogLive anterior a Ubuntu 14.04
|
|
||||||
#install zfsutils # ogLive anterior a Ubuntu 16.04
|
|
||||||
install zfsutils-linux # ogLive a partir de Ubuntu 16.04
|
|
||||||
install android-tools-adb # ogLive a partir de Ubuntu 16.04
|
|
||||||
install android-tools-fastboot # ogLive a partir de Ubuntu 16.04
|
|
||||||
#install android-tools-fsutils # ogLive entre Ubuntu 16.04 y Ubuntu 20.04
|
|
||||||
install f2fs-tools
|
|
|
@ -1,8 +0,0 @@
|
||||||
#sw.filesystem.remote
|
|
||||||
#install nfs-common # Provoca error de instalación en Ubuntu 15.04
|
|
||||||
install sshfs
|
|
||||||
install cifs-utils
|
|
||||||
install smbclient
|
|
||||||
install open-iscsi
|
|
||||||
install openssh-server
|
|
||||||
#install bittornado # ogLive anterior a Ubuntu 20.04
|
|
|
@ -1,12 +0,0 @@
|
||||||
#sw.monitoring
|
|
||||||
install htop
|
|
||||||
install ncdu
|
|
||||||
install bwbar
|
|
||||||
install bmon
|
|
||||||
install iftop
|
|
||||||
install ifstat
|
|
||||||
install dstat
|
|
||||||
install hdparm
|
|
||||||
install sdparm
|
|
||||||
install blktool
|
|
||||||
install testdisk
|
|
|
@ -1,17 +0,0 @@
|
||||||
#sw.networking
|
|
||||||
install netpipes
|
|
||||||
install curl
|
|
||||||
install wget
|
|
||||||
install tftp
|
|
||||||
install dnsutils
|
|
||||||
install trickle
|
|
||||||
install lighttpd
|
|
||||||
install ethtool
|
|
||||||
install ssmping
|
|
||||||
install tcpdump
|
|
||||||
install nmap
|
|
||||||
install arping
|
|
||||||
#install iptraf
|
|
||||||
install ntpdate
|
|
||||||
install ctorrent
|
|
||||||
install udpcast
|
|
|
@ -1,71 +0,0 @@
|
||||||
#sw.other
|
|
||||||
install screen
|
|
||||||
install schroot
|
|
||||||
install xmlstarlet
|
|
||||||
############# UEFI
|
|
||||||
install efibootmgr
|
|
||||||
install efitools
|
|
||||||
install refind
|
|
||||||
install grub-efi-amd64-bin
|
|
||||||
install grub-efi-ia32-bin
|
|
||||||
install grub-pc-bin
|
|
||||||
############# OGAgent
|
|
||||||
#install libxss1
|
|
||||||
#install python-prctl
|
|
||||||
#install python-six
|
|
||||||
#install python-requests
|
|
||||||
##############
|
|
||||||
install fusioninventory-agent
|
|
||||||
install nvme-cli
|
|
||||||
install disktype
|
|
||||||
install laptop-detect
|
|
||||||
#install discover
|
|
||||||
#install casper
|
|
||||||
#install lupin-casper
|
|
||||||
#install xinit
|
|
||||||
#install obconf
|
|
||||||
#install xserver-xorg
|
|
||||||
#install x11-xserver-utils
|
|
||||||
#install xterm network-manager-gnome
|
|
||||||
#install plymouth-x11
|
|
||||||
#install plymouth-label
|
|
||||||
#install plymouth-theme-ubuntu-logo
|
|
||||||
#install pcmanfm
|
|
||||||
#install chromium-browser
|
|
||||||
#install gtk-theme-switch
|
|
||||||
#install gtk2-engines
|
|
||||||
#install murrine-themes
|
|
||||||
####################################3
|
|
||||||
#install gnome-icon-theme
|
|
||||||
#install gnome-brave-icon-theme
|
|
||||||
#install dmz-cursor-theme
|
|
||||||
#install python-wnck
|
|
||||||
#install python-xlib
|
|
||||||
#install python-pyinotify
|
|
||||||
#install python-alsaaudio
|
|
||||||
#install python-vte maximus
|
|
||||||
#install gpicview
|
|
||||||
#install leafpad
|
|
||||||
#install lxappearance
|
|
||||||
#install lxmenu-data
|
|
||||||
#install lxrandr
|
|
||||||
#install lxterminal
|
|
||||||
#install nitrogen
|
|
||||||
#install ttf-ubuntu-font-family
|
|
||||||
#install time
|
|
||||||
#install synaptic
|
|
||||||
#install libglib-perl
|
|
||||||
#install libgtk2-perl
|
|
||||||
#install libxml-simple-perl
|
|
||||||
#install smartmontools
|
|
||||||
#install gnome-disk-utility
|
|
||||||
#install policykit-1-gnome
|
|
||||||
#install policykit-desktop-privileges
|
|
||||||
#install baobab
|
|
||||||
#install lshw-gtk
|
|
||||||
#install usb-creator-gtk
|
|
||||||
#install wodim
|
|
||||||
#install curlftpfs
|
|
||||||
#install libnotify-bin
|
|
||||||
#install cryptsetup
|
|
||||||
#install system-config-lvm
|
|
Before Width: | Height: | Size: 870 B After Width: | Height: | Size: 870 B |
Before Width: | Height: | Size: 296 B After Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 350 B After Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 285 B |
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 285 B |
|
@ -0,0 +1,131 @@
|
||||||
|
[General]
|
||||||
|
|
||||||
|
logging_level = INFO
|
||||||
|
rootfs_image_label = ogClient
|
||||||
|
|
||||||
|
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
|
||||||
|
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 =
|
||||||
|
DEFAULT menu.c32
|
||||||
|
PROMPT 0
|
||||||
|
ALLOWOPTIONS 1
|
||||||
|
|
||||||
|
MENU TITLE OpenGnsys __NAMEISOCLIENT__
|
||||||
|
|
||||||
|
|
||||||
|
LABEL 0
|
||||||
|
MENU LABEL ogLive vga irqpool acpi ogdebug ip:none
|
||||||
|
KERNEL /ogclient/linuxISO
|
||||||
|
APPEND initrd=/ogclient/oginitrd.img ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none
|
||||||
|
|
||||||
|
LABEL 1
|
||||||
|
MENU LABEL ogLive irqpoll acpi ip:none
|
||||||
|
KERNEL /ogclient/linuxISO
|
||||||
|
APPEND initrd=/ogclient/oginitrd.img ro irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=none
|
||||||
|
|
||||||
|
LABEL 2
|
||||||
|
MENU LABEL ogLive acpi debug ip=dhcp
|
||||||
|
KERNEL /ogclient/linuxISO
|
||||||
|
APPEND initrd=/ogclient/oginitrd.img ro acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=dhcp
|
||||||
|
|
||||||
|
LABEL 3
|
||||||
|
MENU LABEL ogLive ip=dhcp
|
||||||
|
KERNEL /ogclient/linuxISO
|
||||||
|
APPEND initrd=/ogclient/oginitrd.img ro acpi=off boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=dhcp
|
||||||
|
|
||||||
|
LABEL 4
|
||||||
|
MENU LABEL local
|
||||||
|
localboot 0x80
|
||||||
|
append -
|
||||||
|
|
||||||
|
label 5
|
||||||
|
MENU LABEL Network boot via gPXE lkrn
|
||||||
|
KERNEL __PXEPKG__.lkrn
|
||||||
|
|
||||||
|
label 6
|
||||||
|
MENU LABEL Network boot via gPXE usb
|
||||||
|
KERNEL __PXEPKG__.usb
|
||||||
|
|
||||||
|
label 7
|
||||||
|
MENU LABEL Network boot via gPXE pxe
|
||||||
|
KERNEL __PXEPKG__.pxe
|
||||||
|
|
||||||
|
label 8
|
||||||
|
MENU LABEL Network boot via gPXE iso
|
||||||
|
KERNEL __PXEPKG__.iso
|
||||||
|
|
||||||
|
label 9
|
||||||
|
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
|
|
@ -0,0 +1,172 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
import subprocess
|
||||||
|
import glob
|
||||||
|
import stat
|
||||||
|
import shutil
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
curdir = os.path.dirname (__file__)
|
||||||
|
sys.path.insert (0, curdir)
|
||||||
|
from boottools import utils, apt, btog
|
||||||
|
|
||||||
|
os.chdir (curdir)
|
||||||
|
|
||||||
|
def _logging (lvl='INFO', logfile='/tmp/boot-tools_installation.log'):
|
||||||
|
numeric_level = getattr (logging, lvl.upper(), None)
|
||||||
|
if numeric_level is None:
|
||||||
|
numeric_level = getattr (logging, 'INFO')
|
||||||
|
|
||||||
|
logging.basicConfig (
|
||||||
|
format='%(levelname)s %(asctime)s (%(funcName)s) %(message)s',
|
||||||
|
level=numeric_level,
|
||||||
|
handlers = [
|
||||||
|
logging.FileHandler (logfile),
|
||||||
|
logging.StreamHandler (sys.stdout),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
return logging.getLogger ('boottools')
|
||||||
|
|
||||||
|
def _mount_rootfs (btrootfsimg, btrootfsmnt):
|
||||||
|
try: utils.mount (btrootfsimg, btrootfsmnt, opts=['-o', 'loop,offset=32256'])
|
||||||
|
except:
|
||||||
|
logger.error ('mount failed')
|
||||||
|
sys.exit (1)
|
||||||
|
|
||||||
|
def _get_pxepkg():
|
||||||
|
pxepkg = None
|
||||||
|
cache = apt.cache_search (['gpxe', 'ipxe'])
|
||||||
|
if cache['gpxe']: pxepkg = 'gpxe'
|
||||||
|
if cache['ipxe']: pxepkg = 'ipxe'
|
||||||
|
if pxepkg is None:
|
||||||
|
logger.error ('neither gpxe nor ipxe found in apt cache')
|
||||||
|
sys.exit (1)
|
||||||
|
logger.info (f'PXE package is "{pxepkg}"')
|
||||||
|
return pxepkg
|
||||||
|
|
||||||
|
def _mkrootfs (btrootfsimg, btrootfsmnt, btrootfsimglabel, btvirtualdisksize, bttargetdir, osarch):
|
||||||
|
logger.info ('Stage 1.1 - create, partition and format the rootfs')
|
||||||
|
rc = subprocess.run (f'file "{btrootfsimg}" |grep -q "partition 1 *: ID=0x83"', shell=True).returncode
|
||||||
|
if (rc): ## 'file|grep' failed
|
||||||
|
try: btog.mkrootfs (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize, bttargetdir, osarch)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error (str (e))
|
||||||
|
sys.exit (1)
|
||||||
|
|
||||||
|
def _debootstrap (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp):
|
||||||
|
logger.info ('Stage 1.2 - debootstrap system')
|
||||||
|
_mount_rootfs (btrootfsimg, btrootfsmnt)
|
||||||
|
try: os.stat (os.path.join (btrootfsmnt, 'etc'))
|
||||||
|
except:
|
||||||
|
logger.debug (f'stat failed, calling btog.debootstrap()')
|
||||||
|
try: btog.debootstrap (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp)
|
||||||
|
except Exception as e:
|
||||||
|
utils.umount (btrootfsmnt)
|
||||||
|
logger.error (str (e))
|
||||||
|
sys.exit (1)
|
||||||
|
utils.umount (btrootfsmnt)
|
||||||
|
|
||||||
|
def _initramfs_version (gitrelease, osrelease, curdir):
|
||||||
|
utils.run (['sed', '-i', f'1 s/$/ {gitrelease} ({osrelease})/', f'{curdir}/includes/etc/initramfs-tools/scripts/VERSION.txt'])
|
||||||
|
|
||||||
|
def _copy_og_files (btrootfsimg, btrootfsmnt, osdistrib, oscodename):
|
||||||
|
_mount_rootfs (btrootfsimg, btrootfsmnt)
|
||||||
|
builder = '/tmp/opengnsys/oglive_builder'
|
||||||
|
og_shared = '/tmp/opengnsys/shared'
|
||||||
|
og_engine = '/tmp/opengnsys/engine'
|
||||||
|
btog.copy_og_files (builder, og_shared, og_engine, btrootfsmnt, osdistrib, oscodename)
|
||||||
|
utils.umount (btrootfsmnt)
|
||||||
|
|
||||||
|
def _chroot_tasks (cfgfile, curdir, osrelease, osarch):
|
||||||
|
logger.debug (f'running \'schroot --chroot IMGogclient -- {curdir}/chroot-tasks.py --osrelease "{osrelease}" --osarch "{osarch}"\'')
|
||||||
|
stdout, _ = utils.run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/chroot-tasks.py', '--osrelease', osrelease, '--osarch', osarch, '--config', cfgfile])
|
||||||
|
## this leaves initrd.img-6.8.0-31-generic and vmlinuz-6.8.0-31-generic in /tmp
|
||||||
|
|
||||||
|
def _ssh_stuff (btrootfsimg, btrootfsmnt):
|
||||||
|
_mount_rootfs (btrootfsimg, btrootfsmnt)
|
||||||
|
btog.ssh_server (btrootfsmnt)
|
||||||
|
btog.ssh_client (btrootfsmnt)
|
||||||
|
utils.umount (btrootfsmnt)
|
||||||
|
## the end result is:
|
||||||
|
## - there's a new key pair in the VM (or docker container), in /root/.ssh
|
||||||
|
## - there's another new key pair in the rootfs, in /var/lib/tftpboot/ogclient/ogclientmount/root/.ssh
|
||||||
|
## - the two pubkeys (one of each pair) end up being authorised in the rootfs, in /var/lib/tftpboot/ogclient/ogclientmount/root/.ssh/authorized_keys
|
||||||
|
|
||||||
|
def _mkinitrd_squashfs_isofs (bttargetdir, osrelease, btrootfsimg, btrootfsmnt, pxepkg, isolinux_tpl, nameisoclient):
|
||||||
|
logger.info ('Stage 4.1 - Put initrd in place')
|
||||||
|
_mount_rootfs (btrootfsimg, btrootfsmnt)
|
||||||
|
btog.move_initrd (bttargetdir, osrelease)
|
||||||
|
|
||||||
|
logger.info ('Stage 4.2 - make squash filesystem')
|
||||||
|
btog.mksquashfs (bttargetdir, btrootfsmnt)
|
||||||
|
utils.umount (btrootfsmnt)
|
||||||
|
|
||||||
|
logger.info ('Stage 4.3 - make iso filesystem')
|
||||||
|
btog.mkisofs (pxepkg, isolinux_tpl, bttargetdir, nameisoclient)
|
||||||
|
|
||||||
|
def _main (cfgfile, config, type_client):
|
||||||
|
isolinux_tpl = config['General'].get ('isolinux_template')
|
||||||
|
btrootfsimglabel = config['General'].get ('rootfs_image_label')
|
||||||
|
|
||||||
|
logger.info ('OpenGnsys CLIENT installation begins')
|
||||||
|
|
||||||
|
fd = open (f'{curdir}/gitrelease', 'r') ## per the Dockerfile
|
||||||
|
gitrelease = fd.readline().strip()
|
||||||
|
fd.close()
|
||||||
|
|
||||||
|
osdistrib, oscodename, osrelease, osarch, oshttp = btog.GetOsInfo (type_client)
|
||||||
|
if osdistrib is None:
|
||||||
|
logger.error ('GetOsInfo() failed')
|
||||||
|
sys.exit (1)
|
||||||
|
bttargetdir, btrootfsimg, btrootfsmnt, btvirtualdisksize = btog.GetVar (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: utils.umount (btrootfsmnt)
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
logger.info ('STAGE 1 - create and bootstrap rootfs')
|
||||||
|
_mkrootfs (btrootfsimg, btrootfsmnt, btrootfsimglabel, btvirtualdisksize, bttargetdir, osarch)
|
||||||
|
_debootstrap (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp)
|
||||||
|
|
||||||
|
logger.info ('STAGE 2 - copy files to the rootfs')
|
||||||
|
_initramfs_version (gitrelease, osrelease, curdir)
|
||||||
|
_copy_og_files (btrootfsimg, btrootfsmnt, osdistrib, oscodename)
|
||||||
|
|
||||||
|
logger.info ('STAGE 3 - perform tasks within the chroot')
|
||||||
|
_chroot_tasks (cfgfile, curdir, osrelease, osarch)
|
||||||
|
|
||||||
|
_ssh_stuff (btrootfsimg, btrootfsmnt)
|
||||||
|
|
||||||
|
logger.info ('STAGE 4 - generate distribution files')
|
||||||
|
pxepkg = _get_pxepkg()
|
||||||
|
nameisoclient = '-'.join (['ogLive', oscodename, osrelease, osarch, gitrelease])
|
||||||
|
_mkinitrd_squashfs_isofs (bttargetdir, osrelease, btrootfsimg, btrootfsmnt, pxepkg, isolinux_tpl, nameisoclient)
|
||||||
|
|
||||||
|
logger.info ('OpenGnsys installation finished')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if os.getuid():
|
||||||
|
print ('ERROR: this program must run under root privileges!!', file=sys.stderr)
|
||||||
|
sys.exit (1)
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument ('--loglevel', help='Log level', action='store')
|
||||||
|
parser.add_argument ('--codename', help='OS codename', action='store')
|
||||||
|
parser.add_argument ('--config', help='Path to configuration file', action='store')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
cfgfile = args.config or 'mkoglive.cfg'
|
||||||
|
config = utils.read_config (cfgfile)
|
||||||
|
if config is None:
|
||||||
|
print ('ERROR: no configuration found', file=sys.stderr)
|
||||||
|
sys.exit (1)
|
||||||
|
cfg_loglevel = config['General'].get ('logging_level')
|
||||||
|
|
||||||
|
logger = _logging (args.loglevel or cfg_loglevel)
|
||||||
|
|
||||||
|
_main (cfgfile, config, args.codename)
|
|
@ -0,0 +1,12 @@
|
||||||
|
# mount.defaults: static file system information for chroots.
|
||||||
|
# Note that the mount point will be prefixed by the chroot path
|
||||||
|
# (CHROOT_PATH)
|
||||||
|
#
|
||||||
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||||
|
proc /proc proc defaults 0 0
|
||||||
|
#procbususb /proc/bus/usb usbfs defaults 0 0
|
||||||
|
#/dev /dev none rw,bind 0 0
|
||||||
|
/dev/pts /dev/pts none rw,bind 0 0
|
||||||
|
/dev/shm /dev/shm none rw,bind 0 0
|
||||||
|
#/home /home none rw,bind 0 0
|
||||||
|
/tmp /tmp none rw,bind 0 0
|
|
@ -0,0 +1,10 @@
|
||||||
|
[IMGogclient]
|
||||||
|
type=loopback
|
||||||
|
file=/var/lib/tftpboot/ogclient/ogclient.img
|
||||||
|
description=ogclient Ubuntu image
|
||||||
|
#priority=1
|
||||||
|
users=root
|
||||||
|
groups=root
|
||||||
|
root-groups=root
|
||||||
|
mount-options=-o offset=32256
|
||||||
|
root-users=root
|