#!/bin/bash

# this is going to be at the root of the project, since the make scripts are called from the root
MMPM_LATEST_VERSION=$(git describe --tags --abbrev=0)
MMPM_INSTALLATION_LOG=$(pwd)/mmpm-$MMPM_LATEST_VERSION-installation-$(date +"%Y-%m-%d").log
MMPM_REQUIRED_PYTHON3_VERSION=3.7

# localhost ports for the server
MMPM_LOCALHOST_PORT=7891
MMPM_WEBSSH_LOCALHOST_PORT=7893
MMPM_CONFIGS_DIR="configs"

# where the localhost ports get proxied to (outward facing)
# AKA, the 'listen' ports in the NGINX config (mmpm.conf)
MMPM_PROXY_PORT=7890
MMPM_WEBSSH_PROXY_PORT=7892
MMPM_HOST_IP=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')

function log_and_eval() {
  echo "[[ MMPM MAKE CMD ]] $1" >> $MMPM_INSTALLATION_LOG
  eval $1 >> $MMPM_INSTALLATION_LOG
}

function log_action() {
  printf "[[ MMPM MAKE ACTION ]] $1\n" >> $MMPM_INSTALLATION_LOG
}

function _done_() {
  printf " -> \e[92mdone\e[0m\n"
}

function log_notice() {
  printf " -- \e[96mlogging all execution to $MMPM_INSTALLATION_LOG\e[0m\n"
}
