Merge branch 'user-story-905' of ssh://ognproject.evlt.uma.es:21987/opengnsys/oginstaller into user-story-905

user-story-905
Nicolas Arenas 2024-10-20 12:05:31 +00:00
commit ac57866cd1
10 changed files with 142 additions and 29 deletions

View File

@ -3,14 +3,15 @@
set -x
set -e
PASSWD_FILE=/home/narenas/passwd
DIR=$(pwd)
DIR=/tmp/ubuntu_scratch
CHROOT_DIR=$DIR/chroot
UBUNTU_CHROOT_DIR=$DIR/ubuntu_chroot
DIST=noble
VARIANT=minbase
CLEAN=${CLEAN:-1}
CLEAN_CHROOT=${CLEAN_CHROOT:-1}
OUTPUT_DIR=/media/sf_Downloads/
UBUNTU_CHROOT_DIR=$DIR/ubuntu_chroot
IMAGE_DIR=$DIR/image
DEBOOT_STRAP_URL=http://mirror.raiolanetworks.com/ubuntu/
@ -81,6 +82,7 @@ then
exec_as_sudo rm -f $OUTPUT_DIR/ubuntu-from-scratch.iso
fi
mkdir -p $IMAGE_DIR
mkdir -p $CHROOT_DIR
# # Copio el script chroot_setup.sh al directorio chroot
cp chroot_setup.sh $CHROOT_DIR
@ -111,11 +113,12 @@ umount_in_host $CHROOT_DIR/dev
umount_in_host $CHROOT_DIR/run
# Compress the chroot
exec_as_sudo mv chroot/image .
mkdir -p $IMAGE_DIR
exec_as_sudo mv $CHROOT_DIR/image $IMAGE_DIR/
# Create squashfs imagesudo
exec_as_sudo mksquashfs $CHROOT_DIR image/casper/filesystem.squashfs \
exec_as_sudo mksquashfs $CHROOT_DIR $IMAGE_DIR/casper/filesystem.squashfs \
-noappend -no-duplicates -no-recovery \
-wildcards \
-comp xz -b 1M -Xdict-size 100% \
@ -142,7 +145,7 @@ umount_in_host $UBUNTU_CHROOT_DIR/run
# Compress the ububtu chroot
exec_as_sudo mksquashfs $UBUNTU_CHROOT_DIR image/casper/filesystem.ubuntu.sqfs \
exec_as_sudo mksquashfs $UBUNTU_CHROOT_DIR $IMAGE_DIR/casper/filesystem.ubuntu.sqfs \
-noappend -no-duplicates -no-recovery \
-wildcards \
-comp xz -b 1M -Xdict-size 100% \
@ -152,7 +155,7 @@ exec_as_sudo mksquashfs $UBUNTU_CHROOT_DIR image/casper/filesystem.ubuntu.sqfs \
# Create ISO image
cd image && \
cd $IMAGE_DIR && \
exec_as_sudo xorriso \
-as mkisofs \
-iso-level 3 \

View File

@ -0,0 +1,9 @@
---
dontChroot: false
verbose: true
script:
- /tmp/opengnsys-configs/component-installer.sh

View File

@ -0,0 +1,12 @@
---
dontChroot: true
verbose: true
script:
- mkdir -p ${ROOT}/tmp/opengnsys-configs
- cp /tmp/opengnsys-installer-configs/* ${ROOT}/tmp/opengnsys-configs
- cp /home/narenas/w/remote_fs/oginstaller/component-installer.sh ${ROOT}/tmp/opengnsys-configs
- chmod 755 ${ROOT}/tmp/opengnsys-configs/component-installer.sh

View File

@ -0,0 +1,9 @@
---
dontChroot: false
verbose: true
script:
- /tmp/opengnsys-configs/component-installer.sh

View File

@ -0,0 +1,12 @@
---
dontChroot: true
verbose: true
script:
- mkdir -p ${ROOT}/tmp/opengnsys-configs
- cp /tmp/opengnsys-installer-configs/* ${ROOT}/tmp/opengnsys-configs
- cp /home/narenas/w/remote_fs/oginstaller/component-installer.sh ${ROOT}/tmp/opengnsys-configs
- chmod 755 ${ROOT}/tmp/opengnsys-configs/component-installer.sh

View File

@ -0,0 +1,6 @@
---
unpack:
- source: "/home/narenas/filesystem.ubuntu.sqfs"
sourcefs: squashfs
destination: "/"

View File

@ -4,6 +4,14 @@ modules-search:
- local
- /usr/lib/x86_64-linux-gnu/calamares/modules
instances:
- id: shell_nonchroot
module: shellprocess
config: shell_nonchroot.conf
- id: shell_chroot
module: shellprocess
config: shell_chroot.conf
sequence:
- show:
- welcome
@ -20,6 +28,8 @@ sequence:
- locale
- keyboard
- users
- shellprocess@shell_nonchroot
- shellprocess@shell_chroot
- initramfs
- bootloader
- umount

View File

@ -0,0 +1 @@
../modules/

View File

@ -0,0 +1,19 @@
#!/usr/bin/bash
# Paso 1: Seleccionar los componentes
# Los componentes a instalar se encuentran en el directorio /tmp/opengnsys-installer-configs
COMPONENTS="ogCore ogGui ogDhcp ogBoot"
CONFIGS_DIR=/tmp/opengnsys-configs
for component in $COMPONENTS
do
config_file="config_${component}.json"
if [ -f $CONFIGS_DIR/$config_file ]; then
echo "Componente $component seleccionado, instalando configuración..."
mkdir -p /opt/opengnsys/$component
mkdir -p /opt/opengnsys/$component/installer
cp $CONFIGS_DIR/$config_file /opt/opengnsys/$component/installer/config.json
continue
fi
done

View File

@ -1,5 +1,10 @@
#!/bin/bash
CONFIGS_DIR=/tmp/opengnsys-installer-configs
rm -rf $CONFIGS_DIR
mkdir -p $CONFIGS_DIR
# Paso 1: Seleccionar los componentes
components=$(yad --list --title="Seleccionar componentes" \
--text="Selecciona los componentes que deseas configurar:" \
@ -17,42 +22,69 @@ if [[ -z "$components" ]]; then
exit 1
fi
# Procesar los componentes seleccionados, eliminando la primera columna (TRUE)
echo $components
IFS="|" read -r -a selected_components <<< "$components"
for component in "${selected_components[@]}"; do
# Extraer solo el nombre del componente (segundo campo)
component_name=$(echo "$component" | cut -d '|' -f 2)
for component in $components; do
selected_component=$(echo "$component" | cut -d '|' -f 2)
# Pedir la configuración específica para cada componente seleccionado
config=$(yad --form --title="Configuración para $component_name" \
--field="IP del servidor" \
--field="Ruta del fichero de configuración" \
--width=400 --height=200 --center)
# Dividir la configuración en IP y ruta del fichero
server_ip=$(echo "$config" | cut -d '|' -f 1)
config_path=$(echo "$config" | cut -d '|' -f 2)
config_file="config_${selected_component}.json"
case $selected_component in
"ogCore")
server_ip=$(echo "$config" | cut -d '|' -f 1)
config_path=$(echo "$config" | cut -d '|' -f 2)
;;
"ogGui")
server_ip=$(echo "$config" | cut -d '|' -f 1)
config_path=$(echo "$config" | cut -d '|' -f 2)
;;
"ogDhcp")
config=$(yad --form --title="Configuración para $selected_component" \
--field="Configuración IP servidor de Boot" \
--field="Interfaces Boot" \
--width=400 --height=200 --center)
ogbootIP=$(echo "$config" | cut -d '|' -f 1)
interfaces=$(echo "$config" | cut -d '|' -f 2)
json_array_interfaces=$(echo "$interfaces" | jq -R 'split(",")')
echo "{\"ogbootIP\": \"$ogbootIP\", \"interfaces\": \"$json_array_interfaces\"}" > $CONFIGS_DIR/"$config_file"
;;
"ogBoot")
config=$(yad --form --title="Configuración para $selected_component" \
--field="ogCore Ip Server" \
--field="ogCore Server" \
--field="ogCore Dir" \
--field="ogBoot GitRepo" \
--field="ogBoot Samba User" \
--field="ogBoot Samba Pass" \
--width=400 --height=200 --center)
ogcore_ip=$(echo "$config" | cut -d '|' -f 1)
ogcore_server=$(echo "$config" | cut -d '|' -f 2)
ogcore_dir=$(echo "$config" | cut -d '|' -f 3)
ogboot_gitrepo=$(echo "$config" | cut -d '|' -f 4)
ogboot_samba_user=$(echo "$config" | cut -d '|' -f 5)
ogboot_samba_pass=$(echo "$config" | cut -d '|' -f 6)
echo "{\"ogcore_ip\": \"$ogcore_ip\", \"ogcore_server\": \"$ogcore_server\", \"ogcore_dir\": \"$ogcore_dir\", \"ogboot_gitrepo\": \"$ogboot_gitrepo\", \"ogboot_samba_user\": \"$ogboot_samba_user\", \"ogboot_samba_pass\": \"$ogboot_samba_pass\"}" > $CONFIGS_DIR/"$config_file"
;;
esac
# Verificar si los campos no están vacíos
if [[ -z "$server_ip" || -z "$config_path" ]]; then
yad --error --text="Debes proporcionar la IP del servidor y la ruta del fichero para $component_name." --center
exit 1
fi
# if [[ -z "$server_ip" || -z "$config_path" ]]; then
# yad --error --text="Debes proporcionar la IP del servidor y la ruta del fichero para $selected_component." --center
# exit 1
# fi
# Guardar la configuración en un archivo (cada componente tiene su archivo JSON)
config_file="./${component_name}_config.json"
config_file="./${selected_component}_config.json"
echo "{\"server_ip\": \"$server_ip\", \"config_path\": \"$config_path\"}" > "$config_file"
# Mostrar un mensaje de éxito
yad --info --text="Configuración guardada en $config_file para $component_name." --center
yad --info --text="Configuración guardada en $config_file para $selected_component." --center
done
# Una vez se ha configurado todo, se puede proceder a la instalación de los componentes
# Ejecutar la instalación con calamares y enviar el log a un archivo
# # Una vez se ha configurado todo, se puede proceder a la instalación de los componentes
# # Ejecutar la instalación con calamares y enviar el log a un archivo
#calamares > installer.log 2>&1 & disown
# #calamares > installer.log 2>&1 & disown
sudo calamares > installer.log 2>&1