diff --git a/docker-compose/technical/docker-compose.technical.yml b/docker-compose/technical/docker-compose.technical.yml index fb13455f..002d03e4 100644 --- a/docker-compose/technical/docker-compose.technical.yml +++ b/docker-compose/technical/docker-compose.technical.yml @@ -68,6 +68,8 @@ services: - 5601:5601 environment: - LOGSPOUT=ignore + - SERVER_HOST=0.0.0.0 + - SERVER_PORT=5601 depends_on: - elasticsearch restart: unless-stopped @@ -138,5 +140,7 @@ services: - GF_AUTH_DISABLE_LOGIN_FORM=true - GF_ANALYTICS_REPORTING_ENABLED=false - GF_ANALYTICS_CHECK_FOR_UPDATES=false + - HTTP_PORT=3000 + - HTTP_ADDR=0.0.0.0 ports: - "7000:3000" diff --git a/setup.sh b/setup.sh new file mode 100644 index 00000000..94838f20 --- /dev/null +++ b/setup.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Function to download a file if it does not exist +download_file() { + local url=$1 + local target_path=$2 + + # Check if the file already exists to avoid re-downloading + if [ ! -f "$target_path" ]; then + echo "Downloading $(basename "$target_path")..." + curl -s -L "$url" -o "$target_path" || { echo "Failed to download $(basename "$target_path"). Exiting."; exit 1; } + else + echo "$(basename "$target_path") already exists. Skipping download." + fi +} + +# Set databases path +GRIDSUITE_DATABASES=$(realpath "DATABASES") +export GRIDSUITE_DATABASES + +# Create the subdirectories with the required file mode +mkdir -p "$GRIDSUITE_DATABASES/cases" "$GRIDSUITE_DATABASES/postgres" "$GRIDSUITE_DATABASES/elasticsearch" "$GRIDSUITE_DATABASES/init" || { echo "Failed to create directories. Exiting."; exit 1; } + +# Change the file mode to 777 for all subdirectories +chmod 777 "$GRIDSUITE_DATABASES/cases" "$GRIDSUITE_DATABASES/postgres" "$GRIDSUITE_DATABASES/elasticsearch" "$GRIDSUITE_DATABASES/init" || { echo "Failed to set permissions. Exiting."; exit 1; } + +echo "Folder structure created under $GRIDSUITE_DATABASES with required permissions." + +# Populate init folder +download_file "https://raw.githubusercontent.com/gridsuite/geo-data/main/src/test/resources/geo_data_substations.json" "$GRIDSUITE_DATABASES/init/geo_data_substations.json" +download_file "https://raw.githubusercontent.com/gridsuite/geo-data/main/src/test/resources/geo_data_lines.json" "$GRIDSUITE_DATABASES/init/geo_data_lines.json" +download_file "https://raw.githubusercontent.com/gridsuite/cgmes-boundary-server/main/src/test/resources/business_processes.json" "$GRIDSUITE_DATABASES/init/business_processes.json" +download_file "https://raw.githubusercontent.com/gridsuite/cgmes-boundary-server/main/src/test/resources/tsos.json" "$GRIDSUITE_DATABASES/init/tsos.json" + +echo "Configuration files downloaded." + +# Update IP +# Capture the first IP address into a variable +target_ip=$(hostname -I | awk '{print $1}') + +# Use the variable as needed +echo "The target IP address is: $target_ip" + +# Find all files in the directory and its subdirectories +find "docker-compose" -type f | while read -r file; do + # Use sed to replace 'localhost' and '172.17.0.1' with 'target_ip' in-place + sed -i "s/localhost/$target_ip/g" "$file" + sed -i "s/172.17.0.1/$target_ip/g" "$file" +done + +# Assuming the Docker Compose file is relative to the script's execution path +cd docker-compose/explicit-profiles || { echo "Failed to change directory. Check if the path is correct. Exiting."; exit 1; } +docker compose --profile suite up -d || { echo "Docker Compose failed to start. Check Docker setup. Exiting."; exit 1; } diff --git a/stop.sh b/stop.sh new file mode 100644 index 00000000..4543e3f8 --- /dev/null +++ b/stop.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Set databases path +GRIDSUITE_DATABASES=$(realpath "DATABASES") +export GRIDSUITE_DATABASES + +# Assuming the Docker Compose file is relative to the script's execution path +cd docker-compose/explicit-profiles || { echo "Failed to change directory. Check if the path is correct. Exiting."; exit 1; } +docker compose --profile suite stop || { echo "Docker Compose failed to stop. Exiting."; exit 1; } \ No newline at end of file