From 877e160d95279073e4c759f7549685cb99cab1ae Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Sun, 20 Oct 2024 13:58:49 +0200 Subject: [PATCH 1/2] refs #996 Set variables to move artifacts outside workdir --- builder.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/builder.sh b/builder.sh index 50779d8..12f7f28 100755 --- a/builder.sh +++ b/builder.sh @@ -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 \ From 91bffa83aab11cc8c7698a09e48b437d5448ec53 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Sun, 20 Oct 2024 14:05:11 +0200 Subject: [PATCH 2/2] =?UTF-8?q?#991=20Inyectar=20parametros=20de=20instala?= =?UTF-8?q?ci=C3=B3n=20recogidos=20por=20yad=20-=20Modifica=20script=20de?= =?UTF-8?q?=20instalaci=C3=B3n=20para=20tratar=20cada=20componente=20por?= =?UTF-8?q?=20separado=20-=20Modifica=20archico=20de=20configuraci=C3=B3n?= =?UTF-8?q?=20de=20calamares=20para=20instanciar=20shell=20dos=20veces,=20?= =?UTF-8?q?una=20para=20copiar=20los=20archivos=20de=20configuraci=C3=B3n?= =?UTF-8?q?=20y=20la=20otra=20para=20ejecutar=20el=20script=20de=20instala?= =?UTF-8?q?ci=C3=B3n=20de=20cada=20componente=20en=20el=20chroot=20-=20Cre?= =?UTF-8?q?a=20el=20directorio=20src=20para=20trabajar=20con=20calamares?= =?UTF-8?q?=20en=20modo=20-d=20y=20no=20tener=20que=20ejecutar=20el=20proc?= =?UTF-8?q?eso=20competo=20-=20Crea=20el=20script=20de=20instalaci=C3=B3n?= =?UTF-8?q?=20que=20se=20lanzar=C3=A1=20en=20el=20chroot=20para=20instalar?= =?UTF-8?q?=20todos=20los=20componentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calamares/modules/shell_chroot.conf | 9 +++ calamares/modules/shell_nonchroot.conf | 12 +++ .../modules/shellprocess/shell_chroot.conf | 9 +++ .../modules/shellprocess/shell_nonchroot.conf | 12 +++ calamares/modules/unpackfs/unpackfs.conf | 6 ++ calamares/settings.conf | 10 +++ calamares/src/modules | 1 + component-installer.sh | 19 +++++ openGnsys-installer.sh | 78 +++++++++++++------ 9 files changed, 133 insertions(+), 23 deletions(-) create mode 100644 calamares/modules/shell_chroot.conf create mode 100644 calamares/modules/shell_nonchroot.conf create mode 100644 calamares/modules/shellprocess/shell_chroot.conf create mode 100644 calamares/modules/shellprocess/shell_nonchroot.conf create mode 100644 calamares/modules/unpackfs/unpackfs.conf create mode 120000 calamares/src/modules create mode 100644 component-installer.sh diff --git a/calamares/modules/shell_chroot.conf b/calamares/modules/shell_chroot.conf new file mode 100644 index 0000000..4c0565c --- /dev/null +++ b/calamares/modules/shell_chroot.conf @@ -0,0 +1,9 @@ +--- + +dontChroot: false +verbose: true +script: + - /tmp/opengnsys-configs/component-installer.sh + + + diff --git a/calamares/modules/shell_nonchroot.conf b/calamares/modules/shell_nonchroot.conf new file mode 100644 index 0000000..7719f8d --- /dev/null +++ b/calamares/modules/shell_nonchroot.conf @@ -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 + + + diff --git a/calamares/modules/shellprocess/shell_chroot.conf b/calamares/modules/shellprocess/shell_chroot.conf new file mode 100644 index 0000000..4c0565c --- /dev/null +++ b/calamares/modules/shellprocess/shell_chroot.conf @@ -0,0 +1,9 @@ +--- + +dontChroot: false +verbose: true +script: + - /tmp/opengnsys-configs/component-installer.sh + + + diff --git a/calamares/modules/shellprocess/shell_nonchroot.conf b/calamares/modules/shellprocess/shell_nonchroot.conf new file mode 100644 index 0000000..7719f8d --- /dev/null +++ b/calamares/modules/shellprocess/shell_nonchroot.conf @@ -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 + + + diff --git a/calamares/modules/unpackfs/unpackfs.conf b/calamares/modules/unpackfs/unpackfs.conf new file mode 100644 index 0000000..4f99bff --- /dev/null +++ b/calamares/modules/unpackfs/unpackfs.conf @@ -0,0 +1,6 @@ +--- +unpack: + - source: "/home/narenas/filesystem.ubuntu.sqfs" + sourcefs: squashfs + destination: "/" + diff --git a/calamares/settings.conf b/calamares/settings.conf index a7abc63..66c58fc 100644 --- a/calamares/settings.conf +++ b/calamares/settings.conf @@ -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 diff --git a/calamares/src/modules b/calamares/src/modules new file mode 120000 index 0000000..43aab75 --- /dev/null +++ b/calamares/src/modules @@ -0,0 +1 @@ +../modules/ \ No newline at end of file diff --git a/component-installer.sh b/component-installer.sh new file mode 100644 index 0000000..37ccd0c --- /dev/null +++ b/component-installer.sh @@ -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 diff --git a/openGnsys-installer.sh b/openGnsys-installer.sh index 7ecf4ab..025113b 100644 --- a/openGnsys-installer.sh +++ b/openGnsys-installer.sh @@ -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