#!/usr/bin/env bash

# Install Miniconda.
echo ""
echo "Installing a fresh version of Miniconda."
MINICONDA_URL="https://repo.continuum.io/miniconda"

MINICONDA_FILE="Miniconda3-latest-Linux-x86_64.sh"
if [[ "$OSTYPE" == "darwin"* ]]; then
  MINICONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh"
fi

curl -L "${MINICONDA_URL}/${MINICONDA_FILE}" -o ~/${MINICONDA_FILE}

# Update an existing miniconda installation, if it exists
bash ~/$MINICONDA_FILE -b -u

# Clean up
rm -f ~/${MINICONDA_FILE}

# Configure conda.
echo ""
echo "Configuring conda."
source ~/miniconda3/bin/activate root
conda config --add channels conda-forge --add channels defaults
conda config --set show_channel_urls true
conda install --yes --quiet conda-build
source deactivate
