#!/usr/bin/bash
# used by ./ob/cmd/* scripts ran by this ./launcher
. ./cmd/_colors
. ./cmd/utils

export node=`which node`
export python3=`which python`
export docker_path=`which docker`
export git_path=`which git`
export is_windows=get_is_windows


# https://docs.docker.com/compose/environment-variables/envvars/
# export COMPOSE_PROJECT_NAME="ob_alpha"
export DOCKER_RESTART_POLICY=yes
export COMPOSE_ENV_FILES="$(pwd)/.env.alpha"
export COMPOSE_FILE="$(pwd)/alpha-compose.yml"
export OB_COMPOSE_OVERRIDE="$(pwd)/alpha-compose.override.yml"

ob_compose() {
    "$docker_path" compose -f $COMPOSE_FILE -f $OB_COMPOSE_OVERRIDE "$@"
}

# Colored logs...
function heading() { printf "$(c B1)[OSINTBuddy: $OB_CMD] ${WHITE}${1}${reset}\n"; }
function warning() { printf "${BLUE}[OSINTBuddy: $OB_CMD] ${YELLOW}${1}${reset}\n"; }
function error() { printf "${BLUE}[OSINTBuddy: $OB_CMD] ${red}${1}${reset}\n"; }
function success() { printf "${BLUE}[OSINTBuddy: $OB_CMD] ${green}${1:-Completed successfully!}${reset}\n"; }
function info() { printf "${BLUE}[OSINTBuddy: $OB_CMD] ${CYAN}${1:-''}${reset}\n"; }
function abort() { printf "${BLUE}[OSINTBuddy: $OB_CMD] ${RED}${1:-Aborting!}${reset}\n\n"; exit 1; }

function print_access_urls() {
    info "Once ready you can access OSINTBuddy through the following URLs:"
    info "      http://localhost:3000        - frontend"
    info "      http://localhost:45910       - casdoor"
    info "      http://localhost:48997/docs  - docs"
    info "      http://localhost:48997/api   - backend"
}
