#!/bin/bash set -e 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 docker-compose down chmod 744 ./elk/elasticsearch/index_init.sh 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 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!" docker exec opencdmp.elasticsearch /usr/share/elasticsearch/config/index_init.sh 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!" docker-compose up -d