#!/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 < /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 < /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