#!/bin/bash
# ===========================================================================
# Copyright (c) 2021 Eclipse Foundation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#    Christopher Guindon (Eclipse Foundation)
# ==========================================================================

# Import helper functions for this script
if [[ ! -f "../_shared/bash/import-helpers.sh" ]]
then
  echo 'Exiting... This script is not meant to be exectuted directly. See the Makefile of the project for more info.'
  exit 0
fi
source ../_shared/bash/import-helpers.sh

# Database
MARIADB_CONTAINER_NAME=$(docker-compose ps -q mariadb)

# Print project info
echo_project_info

# import eclipsefoundation database
DATABASE_FILE="../_shared/sql/private/eclipsefoundation.sql.gz"
if test -f "$DATABASE_FILE"; then
    DATABASE_NAME=eclipsefoundation
    import_db_docker
fi

# import eclipse database
DATABASE_FILE="../_shared/sql/private/eclipse.sql.gz"
if test -f "$DATABASE_FILE"; then
    DATABASE_NAME=eclipse
    import_db_docker
fi