#!/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

# Project Info
PROJECT=api.eclipse.org
REMOTE_HOST=api-vm1

# Mariadb container name
MARIADB_CONTAINER_NAME=$(docker compose ps -q mariadb)

# Print project info
echo_project_info

# Ensure that the sql folder exist
mkdir -p sql

# import project database
DATABASE_FILE="api.eclipse.org.sql.gz"
DATABASE_NAME=dev_drupal7_eclipse_api
scp $REMOTE_HOST:webdev/sql/$DATABASE_FILE sql/
import_db_docker

DATABASE_FILE="accounts.eclipse.org.sql.gz"
DATABASE_NAME=dev_drupal7_eclipse_accounts
scp $REMOTE_HOST:webdev/sql/$DATABASE_FILE sql/
import_db_docker

DATABASE_FILE="eclipse_accounts_shared.sql.gz"
DATABASE_NAME=dev_drupal7_eclipse_accounts_shared
scp $REMOTE_HOST:webdev/sql/$DATABASE_FILE sql/
import_db_docker