#!/bin/bash if [ $# -eq 2 ] then INSTALLDIR=$1 ENVNAME=$2 else echo "please try add-strudel2-conda INSTALLDIR ENVNAME" echo "where INSTALLDIR is a path to miniconda that can be activated" echo "and ENVNAME is the name of an environment" fi SCRIPT=$(readlink -f $0) # Get the base directory # The section below sets up the paths to executable files and templates JQ=`dirname $SCRIPT`/jq TEMPLATE=`dirname $SCRIPT`/conda-env-jupyter.sh.template WORKINGDIR=$INSTALLDIR APPSJSON=/home/$USER/.strudel2/apps.json APPSJSONTEMPFILE=/home/$USER/.strudel2/apps.json.temp APPSJSONNEW=/home/$USER/.strudel2/apps.json.new APPSJSONTEMPLATE=`dirname $SCRIPT`/conda-env-jupyter-apps.json.template mkdir -p ~/.strudel2/ cp -rf $TEMPLATE ~/.strudel2/conda-env-jupyter.sh chmod +x ~/.strudel2/conda-env-jupyter.sh # Configure Custom Name for apps.json WORKINGDIRSUBS=`echo "${INSTALLDIR//\//.}"` # Need this to remove the / from the template since it breaks Slurm sed -e "s|LOCATION|${WORKINGDIRSUBS}|g" $APPSJSONTEMPLATE > $APPSJSONTEMPFILE sed -i -e "s|INSTALLDIR|${INSTALLDIR}|g" $APPSJSONTEMPFILE sed -i -e "s|ENVNAME|${ENVNAME}|g" $APPSJSONTEMPFILE # This will check whether the apps.json already exists # If it does, use the jq binary to append the template into existing file # Else, just copy the template file over. if [ -f $APPSJSON ] then $JQ -s '.[0] + .[1]' $APPSJSON $APPSJSONTEMPFILE > $APPSJSONNEW rm $APPSJSON mv $APPSJSONNEW $APPSJSON else mv $APPSJSONTEMPFILE $APPSJSON fi rm -rf $APPSJSONTEMPFILE # Configure Jupyter Notebook for Strudel2 echo $INSTALLDIR >> ~/.jupyterenv mkdir -p ~/.strudel2/ sed -e "s|LOCATION|${WORKINGDIR}|g" $TEMPLATE > ~/.strudel2/jupyter.sh chmod +x ~/.strudel2/jupyter.sh echo "Strudel2 is now configured to use your conda environment."