#!/bin/bash

# Set global configuration
DATA_ROOT="/var/trakqr"
POSTGRES_VERSION="latest"
MONGODB_VERSION="latest"

# Start PostgreSQL
if [ "$(docker ps -a -q -f name=^TRAKQR_POSTGRES$)" ]; then
  echo "PostgreSQL container exists. Starting..."
  docker start TRAKQR_POSTGRES
else
  echo "PostgreSQL container does not exist. Creating..."
  docker run -d \
    --name TRAKQR_POSTGRES \
    -v "${DATA_ROOT}/postgres:/var/lib/postgresql/data" \
    -p 5400:5432 \
    -e POSTGRES_USER=sa \
    -e POSTGRES_PASSWORD=P@ssword123! \
    -e POSTGRES_DB=trakqr \
    postgres:$POSTGRES_VERSION
fi

