#!/usr/bin/env bash

# This file contains the environment variables used by the shell scripts and docker-compose file
# It must be named this so docker-compose will use it, it is currently hard-coded into docker-compose

# System/VM Variables
CUSTOM_PROFILE_FILENAME=custom.sh
COMPOSE_PROJECT_NAME=mms

## Docker Installation Variables
DOCKER_CE_REPO_URL=https://download.docker.com/linux/centos/docker-ce.repo

## Docker Compose Installation Variables
DOCKER_COMPOSE_BASE_URL=https://github.com/docker/compose/releases/download
DOCKER_COMPOSE_LOCATION=/usr/local/bin/docker-compose
DOCKER_COMPOSE_VERSION="1.23.2"

# PostgreSQL Variables (db service)
PG_IMAGE=postgres:9.4-alpine
PG_SERVICE_NAME=db
PG_PORT=5432
PG_DB_NAME=mms
PG_USERNAME=mmsuser
PG_PASSWORD=SoM3sUp3r5ECRETpAs5w0rD
PG_DB_CREATION_COMMAND="create table if not exists organizations (   id bigserial primary key,   orgId text not null,   orgName text not null,   constraint unique_organizations unique(orgId, orgName) ); create index orgId on organizations(orgId);  create table projects (   id bigserial primary key,   projectId text not null,   orgId integer references organizations(id),   name text not null,   location text not null,   constraint unique_projects unique(orgId, projectId) ); create index projectIdIndex on projects(projectid);"
PG_TEST_CREATEDB_ROLE_COMMAND="select rolcreatedb from pg_roles where rolname = current_user"
PG_WAIT=10

# Elasticsearch Variables (search service)
ES_IMAGE=elasticsearch:5.5
ES_SERVICE_NAME=search
ES_PORT=9200
ES_MAPPING_TEMPLATE_FILE=/vagrant/mapping_template.json
ES_CONFIG_FILE=/vagrant/elasticsearch.yml
# ES_MAPPING_TEMPLATE_URL=https://github.com/Open-MBEE/mms/raw/develop/mms-ent/repo-amp/src/main/resources/mapping_template.json
ES_MAX_MAP_COUNT=262144
ES_SYSCTL_CONF_FILE=/usr/lib/sysctl.d/90-elastic-search.conf
ES_WAIT=10

# MMS Variables (web service)
CATALINA_OPTS="-Xmx1G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:G1HeapRegionSize=8m -XX:MaxGCPauseMillis=200"
MMS_IMAGE=openmbee/mms:3.4.2
MMS_EXTERNAL_PORT=8080
MMS_ALFRESCO_DATA_DIR=/mnt/alf_data
MMS_USERNAME=admin
MMS_PASSWORD=admin

# Apache Jena variables
JENA_VERSION=3.5.0
jena() {
    if [[ $@ == "-h" ]]; then
        docker run stain/jena:${JENA_VERSION} ls /jena/bin
    else
        docker run stain/jena:${JENA_VERSION} $@
    fi
}

# Apache Jena Fuseki variables
MMS_SPARQL_SERVER_NAME="fuseki"
MMS_SPARQL_ENDPOINT=http://localhost:13030/ds
export MMS_MAX_REQUESTS=32
export MMS_MAX_SOCKETS=32