#905 prepare eerything before change to docker
parent
2523a16bab
commit
59577c48af
|
@ -6,3 +6,5 @@ operations:
|
|||
- install:
|
||||
- vim
|
||||
- git
|
||||
- isc-dhcp-client
|
||||
- jq
|
||||
|
|
|
@ -4,6 +4,8 @@ dontChroot: false
|
|||
verbose: true
|
||||
script:
|
||||
- /opengnsys-installer/component-installer.sh
|
||||
|
||||
timeout: 600
|
||||
verbose: true
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
#!/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":HIDE \
|
||||
--width=400 --height=200 --center)
|
||||
user=$(echo "$config" | cut -d '|' -f 1)
|
||||
password=$(echo "$config" | cut -d '|' -f 2)
|
||||
echo "{\"username\": \"$user\", \"password\": \"$password\"}" > $CONFIGS_DIR/"$config_file"
|
||||
;;
|
||||
"ogGui")
|
||||
config=$(yad --form --title="Configuración para $selected_component" \
|
||||
--field="IP del servidor de ogCore" \
|
||||
--width=400 --height=200 --center)
|
||||
ogcore_ip=$(echo "$config" | cut -d '|' -f 1)
|
||||
echo "{\"ogcore_ip\": \"$ogcore_ip\"}" > $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
|
|
@ -24,11 +24,14 @@ sequence:
|
|||
- partition
|
||||
- mount
|
||||
- unpackfs
|
||||
- fstab
|
||||
- packages
|
||||
- machineid
|
||||
- locale
|
||||
- keyboard
|
||||
- users
|
||||
- networkcfg
|
||||
- hwclock
|
||||
- shellprocess@shell_nonchroot
|
||||
- shellprocess@shell_chroot
|
||||
- initramfs
|
||||
|
|
|
@ -5,6 +5,96 @@
|
|||
|
||||
# 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() {
|
||||
# Leer el JSON y extraer los valores con jq
|
||||
user=$(jq -r '.username' /opt/opengnsys/ogCore/installer/config.json)
|
||||
password=$(jq -r '.password' /opt/opengnsys/ogCore/installer/config.json)
|
||||
|
||||
# Exportar los valores como variables de entorno
|
||||
export USER_NAME="$user"
|
||||
export USER_PASSWORD="$password"
|
||||
cd /opt/opengnsys/ogCore/repo
|
||||
git checkout develop
|
||||
docker compose up --build -d
|
||||
docker exec ogcore-php composer install
|
||||
docker exec ogcore-php php bin/console lexik:jwt:generate-keypair --overwrite
|
||||
docker exec ogcore-php php bin/console doctrine:migrations:migrate --no-interaction
|
||||
docker exec ogcore-php php bin/console doctrine:fixtures:load --no-interaction
|
||||
|
||||
curl -k -X 'POST' \
|
||||
'https://localhost:8443/auth/login' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{
|
||||
\"username\": \"$USER_NAME\",
|
||||
\"password\": \"$USER_PASSWORD\"
|
||||
}"
|
||||
docker compose down
|
||||
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/local/bin/docker-compose up -d
|
||||
ExecStop=/usr/local/bin/docker-compose down
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl enable ogcore
|
||||
|
||||
}
|
||||
|
||||
function install_oggui_docker() {
|
||||
# Leer el JSON y extraer los valores con jq
|
||||
ogcore_ip=$(jq -r '.ogcore_ip' /opt/opengnsys/ogGui/installer/config.json)
|
||||
oggui_version=$(jq -r '.container_version' /opt/opengnsys/ogGui/installer/config.json)
|
||||
# Exportar los valores como variables de entorno
|
||||
export OGCORE_IP="$ogcore_ip"
|
||||
ENV_DIR=/opt/opengnsys/ogGui/etc/
|
||||
ENV_FILE=$ENV_DIR/.env
|
||||
mkdir -p $ENV_DIR
|
||||
echo "NG_APP_BASE_API_URL=$OGCORE_IP" > $ENV_FILE
|
||||
|
||||
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
|
||||
ExecStart=/usr/bin/docker run --name ogGui-app -p 4200:4200 -v $ENV_FILE:/app/.env -d opengnsys/oggui:$oggui_version
|
||||
ExecStop=/usr/bin/docker stop angular-app
|
||||
ExecStopPost=/usr/bin/docker rm -f angular-app
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl enable oggui-app
|
||||
|
||||
}
|
||||
|
||||
|
||||
COMPONENTS="ogCore ogGui ogDhcp ogBoot ogRepository"
|
||||
CONFIGS_DIR=/opengnsys-installer/
|
||||
PAT_FILE=/opengnsys-installer/pat.txt
|
||||
|
@ -39,12 +129,16 @@ do
|
|||
ogCore)
|
||||
echo "Instalando ogCore..."
|
||||
git clone "$OGCORE_REPO" "$component_dir/repo"
|
||||
echo - ogCore >> /etc/issue
|
||||
echo - ogCore >> /etc/issueq
|
||||
install_docker
|
||||
install_ogcore_docker
|
||||
;;
|
||||
ogGui)
|
||||
echo "Instalando ogGui..."
|
||||
git clone "$OGGUI_REPO" "$component_dir/repo"
|
||||
echo - ogGui >> /etc/issue
|
||||
install_docker
|
||||
install_oggui_docker
|
||||
;;
|
||||
ogDhcp)
|
||||
echo "Instalando ogDhcp..."
|
||||
|
|
|
@ -31,12 +31,20 @@ for component in $components; do
|
|||
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)
|
||||
config=$(yad --form --title="Configuración para $selected_component" \
|
||||
--field="Usuario administrador":TEXT \
|
||||
--field="Contraseña":HIDE \
|
||||
--width=400 --height=200 --center)
|
||||
user=$(echo "$config" | cut -d '|' -f 1)
|
||||
password=$(echo "$config" | cut -d '|' -f 2)
|
||||
echo "{\"username\": \"$user\", \"password\": \"$password\"}" > $CONFIGS_DIR/"$config_file"
|
||||
;;
|
||||
"ogGui")
|
||||
server_ip=$(echo "$config" | cut -d '|' -f 1)
|
||||
config_path=$(echo "$config" | cut -d '|' -f 2)
|
||||
config=$(yad --form --title="Configuración para $selected_component" \
|
||||
--field="IP del servidor de ogCore" \
|
||||
--width=400 --height=200 --center)
|
||||
ogcore_ip=$(echo "$config" | cut -d '|' -f 1)
|
||||
echo "{\"ogcore_ip\": \"$ogcore_ip\"}" > $CONFIGS_DIR/"$config_file"
|
||||
;;
|
||||
"ogDhcp")
|
||||
config=$(yad --form --title="Configuración para $selected_component" \
|
||||
|
|
Loading…
Reference in New Issue