Reestructura de los directorios
oginstaller/pipeline/head There was a failure building this commit Details

ogrepo-keys
Nicolas Arenas 2025-02-06 11:53:34 +01:00
parent 625c464ff5
commit b652142aaa
55 changed files with 2 additions and 254 deletions

View File

@ -1,150 +0,0 @@
#!/usr/bin/bash
# Paso 1: Seleccionar los componentes
# Los componentes a instalar se encuentran en el directorio /tmp/opengnsys-installer-configs
# Set configuration
function install_docker() {
apt-get -y update
apt-get -y install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get -y update
apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable docker
}
function install_ogcore_docker() {
cat <<EOF > /etc/systemd/system/ogcore.service
[Unit]
Description=Servicio para ejecutar Docker Compose de ogCore
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/opt/opengnsys/ogCore/repo/
ExecStart=/usr/bin/docker compose -f /opt/opengnsys/ogCore/etc/docker-compose-deploy.yml up
ExecStartPost=/opengnsys-installer/provision_ogcore.sh
ExecStop=/usr/bin/docker compose -f /opt/opengnsys/ogCore/etc/docker-compose-deploy.yml stop
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now ogcore
}
function install_oggui_docker() {
# Sacar la IP del ogCore de la configuración
oggui_version=$(jq -r '.container_version' /opt/opengnsys/ogGui/installer/config.json)
# Exportar los valores como variables de entorno
ENV_DIR=/opt/opengnsys/ogGui/etc/
ENV_FILE=$ENV_DIR/.env
cat <<EOF > /etc/systemd/system/oggui-app.service
[Unit]
Description=Servicio para contenedor Docker de OgGui
After=docker.service
Requires=docker.service
[Service]
Restart=always
ExecStartPre=/opengnsys-installer/provision_oggui.sh
ExecStart=/usr/bin/docker run --rm --name ogGui-app -p 4200:4200 -v $ENV_FILE:/app/.env opengnsys/oggui:$oggui_version
ExecStop=/usr/bin/docker stop ogGui-app
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now oggui-app
}
COMPONENTS="ogCore ogGui ogDhcp ogBoot ogRepository"
CONFIGS_DIR=/opengnsys-installer/
PAT_FILE=/opengnsys-installer/pat.txt
PAT=$(cat $PAT_FILE | tr -d '\n\r\t')
OPENGNSYS_BASE_URL="https://$PAT@ognproject.evlt.uma.es/gitea/opengnsys"
OGBOOT_REPO="$OPENGNSYS_BASE_URL/ogboot.git"
OGCORE_REPO="$OPENGNSYS_BASE_URL/ogcore.git"
OGDHCP_REPO="$OPENGNSYS_BASE_URL/ogdhcp.git"
OGGUI_REPO="$OPENGNSYS_BASE_URL/oggui.git"
OGREPOSITORY_REPO="$OPENGNSYS_BASE_URL/ogrepository.git"
export GIT_SSL_NO_VERIFY=1
echo ======================================== > /etc/issue
echo "OpenGnSys Installer" >> /etc/issue
echo "Componentes instalados:" >> /etc/issue
for component in $COMPONENTS
do
config_file="config_${component}.json"
if [ -f $CONFIGS_DIR/$config_file ]; then
echo "Componente $component seleccionado, instalando configuración..."
component_dir=/opt/opengnsys/$component
mkdir -p $component_dir/installer
mkdir -p $component_dir/repo
cp $CONFIGS_DIR/$config_file /opt/opengnsys/$component/installer/config.json
case $component in
ogCore)
echo "Instalando ogCore..."
OGCORE_BRANCH=main
container_version=$(jq -r '.container_version' /opt/opengnsys/ogCore/installer/config.json)
git clone --branch "$OGCORE_BRANCH" "$OGCORE_REPO" "$component_dir/repo"
# Copy the docker-compose-deploy.yml file to /opt/opengnsys/ogCore/etc/
mkdir -p $component_dir/etc/
cp $component_dir/repo/docker-compose-deploy.yml $component_dir/etc/
sed -i "s/static/$container_version/g" $component_dir/repo/docker-compose-deploy.yml
echo - ogCore >> /etc/issue
install_docker
install_ogcore_docker
;;
ogGui)
echo "Instalando ogGui..."
OGGUI_BRANCH=main
git clone --branch "$OGGUI_BRANCH" "$OGGUI_REPO" "$component_dir/repo"
echo - ogGui >> /etc/issue
install_docker
install_oggui_docker
;;
ogDhcp)
echo "Instalando ogDhcp..."
git clone "$OGDHCP_REPO" "$component_dir/repo"
echo - ogDhcp >> /etc/issue
;;
ogBoot)
echo "Instalando ogBoot..."
git clone "$OGBOOT_REPO" "$component_dir/repo"
echo - ogBoot >> /etc/issue
;;
ogRepository)
echo "Instalando ogRepository..."
git clone "$OGREPOSITORY_REPO" "$component_dir/repo"
echo - ogRepository >> /etc/issue
;;
*)
echo "Componente $component no reconocido"
;;
esac
continue
fi
done
echo ======================================== >> /etc/issue
rm -f $PAT_FILE

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -10,6 +10,7 @@ OGPASS=${4:-"og"}
INSTALL_DIR=/opt/opengnsys/ogrepository
DOWNLOAD_DIR=${5:-"/tmp/ogrepository"}
DEBIAN_FRONTEND=noninteractive
OGUSER_HOME=/opt/opengnsys
export DEBIAN_FRONTEND
export GIT_SSL_NO_VERIFY
@ -34,7 +35,7 @@ install_updcast () {
add_user_ogrepository() {
if ! id "$OGUSER" &>/dev/null; then
echo "User ogrepository does not exist, creating it"
useradd -r -s /bin/bash $OGUSER
useradd -m -d $OGUSER_HOME -r -s /bin/bash $OGUSER
fi
if [ ! -f /etc/sudoers.d/$OGUSER ]; then
echo "User $OGUSER does not have sudo permissions, adding it"

View File

@ -1,103 +0,0 @@
#!/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