argos/deployment/deploy_opencdmp.sh

79 lines
1.9 KiB
Bash
Raw Normal View History

2024-05-13 15:30:25 +02:00
#!/bin/bash
set -e
2024-05-13 16:24:08 +02:00
networks=("opencdmp-elastic-shared-network" "opencdmp-gotenberg-shared-network" "opencdmp-keycloak-shared-network" "opencdmp-postgres-shared-network" "opencdmp-rabbitmq-shared-network")
network_exists() {
local name="$1"
docker network inspect "$name" >/dev/null 2>&1
}
for network in "${networks[@]}"; do
if ! network_exists "$network"; then
echo "Creating network: $network"
docker network create "$network"
if [ $? -eq 0 ]; then
echo "Network $network created successfully."
else
echo "Failed to create network $network."
fi
else
echo "Network $network already exists."
fi
done
2024-05-13 15:30:25 +02:00
docker-compose down
2024-05-14 15:37:57 +02:00
docker-compose pull
2024-05-13 15:30:25 +02:00
2024-05-13 16:24:08 +02:00
chmod 744 ./elk/elasticsearch/index_init.sh
2024-05-13 15:30:25 +02:00
2024-05-13 16:24:08 +02:00
recreate_directories() {
echo "Resetting postgres and elasticsearch..."
sudo rm -rf ./storage/postgres/data
mkdir -p ./storage/postgres/data
sudo rm -rf ./storage/elasticsearch
mkdir -p ./storage/elasticsearch
}
if [[ $1 == "-r" ]]; then
recreate_directories
fi
2024-05-13 15:30:25 +02:00
docker-compose up -d opencdmp.elasticsearch
function loading_icon() {
local load_interval="${1}"
local loading_message="${2}"
local elapsed=0
local loading_animation=( '—' "\\" '|' '/' )
echo -n "${loading_message} "
tput civis
trap "tput cnorm" EXIT
while [ "${load_interval}" -ne "${elapsed}" ]; do
for frame in "${loading_animation[@]}" ; do
printf "%s\b" "${frame}"
sleep 0.25
done
elapsed=$(( elapsed + 1 ))
done
printf " \b\n"
}
loading_icon 45 "Waiting for Elasticsearch to Startup!"
2024-05-14 08:49:56 +02:00
docker exec opencdmp.elasticsearch /usr/share/elasticsearch/config/index_init.sh
2024-05-13 15:30:25 +02:00
docker restart opencdmp.elasticsearch
docker-compose up -d opencdmp.postgres
loading_icon 20 "Waiting for PostgreSQL to Initialize!"
docker-compose up -d opencdmp.keycloak
loading_icon 60 "Waiting for Keycloak to Startup!"
2024-05-13 16:24:08 +02:00
docker-compose up -d