104 lines
4.3 KiB
Bash
104 lines
4.3 KiB
Bash
#!/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:" \
|
|
--checklist --multiple \
|
|
--column="Seleccionar" --column="Componente" \
|
|
FALSE "ogCore" \
|
|
FALSE "ogGui" \
|
|
FALSE "ogDhcp" \
|
|
FALSE "ogBoot" \
|
|
--width=400 --height=300 --center)
|
|
|
|
# Verificar si el usuario seleccionó algún componente
|
|
if [[ -z "$components" ]]; then
|
|
yad --info --text="No seleccionaste ningún componente. Saliendo..." --center
|
|
exit 1
|
|
fi
|
|
|
|
for component in $components; do
|
|
selected_component=$(echo "$component" | cut -d '|' -f 2)
|
|
# Pedir la configuración específica para cada componente seleccionado
|
|
|
|
|
|
# Dividir la configuración en IP y ruta del fichero
|
|
config_file="config_${selected_component}.json"
|
|
case $selected_component in
|
|
"ogCore")
|
|
config=$(yad --form --title="Configuración para $selected_component" \
|
|
--field="Usuario administrador":TEXT \
|
|
--field="Contraseña":H \
|
|
--field="Tag del contenedor":TEXT \
|
|
"ogadmin" "" "latest" \
|
|
--width=400 --height=200 --center)
|
|
user=$(echo "$config" | cut -d '|' -f 1)
|
|
password=$(echo "$config" | cut -d '|' -f 2)
|
|
container_tag=$(echo "$config" | cut -d '|' -f 3)
|
|
echo "{\"username\": \"$user\", \"password\": \"$password\", \"container_version\": \"$container_tag\" }" > $CONFIGS_DIR/"$config_file"
|
|
;;
|
|
"ogGui")
|
|
config=$(yad --form --title="Configuración para $selected_component" \
|
|
--field="IP del servidor de ogCore" \
|
|
--field="Tag del contenedor":TEXT \
|
|
--width=400 --height=200 --center)
|
|
ogcore_ip=$(echo "$config" | cut -d '|' -f 1)
|
|
container_version=$(echo "$config" | cut -d '|' -f 2)
|
|
echo "{\"ogcore_ip\": \"$ogcore_ip\" , \"container_version\": \"$container_version\" }" > $CONFIGS_DIR/"$config_file"
|
|
;;
|
|
"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 $selected_component." --center
|
|
# exit 1
|
|
# fi
|
|
|
|
# Guardar la configuración en un archivo (cada componente tiene su archivo 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 $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
|
|
|
|
# #calamares > installer.log 2>&1 & disown
|
|
sudo calamares > installer.log 2>&1
|