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