Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
download-and-install-mambaforge 939 B
#!/bin/bash

# This script will download and install mambaforge if it's not present where expected
#
# Expected args:
#   1. EXPECTED_MAMBAFORGE_PATH: path to where mambaforge should be installed
#   2. EXPECTED_CONDA_PATH: path to the conda executable

EXPECTED_MAMBAFORGE_PATH=$1
EXPECTED_CONDA_PATH=$2

MAMBAFORGE_SCRIPT_NAME=Mambaforge-$(uname)-$(uname -m).sh
URL=https://github.com/conda-forge/miniforge/releases/latest/download/$MAMBAFORGE_SCRIPT_NAME

# Ensure conda is installed
if [[ ! -f $EXPECTED_CONDA_PATH ]]; then
    if [[ ! -f $MAMBAFORGE_SCRIPT_NAME ]]; then
        # Download mambaforge
        if [ -x "$(which curl)" ]; then
            curl -L -O $URL
        elif [ -x "$(which wget)" ] ; then
            wget $URL
        else
            echo "Could not download Conda as wget and curl are not installed."
            exit 1
        fi
    fi
    bash $MAMBAFORGE_SCRIPT_NAME -b
    rm $MAMBAFORGE_SCRIPT_NAME
fi