Skip to content

Commit

Permalink
try catch for uninstalled files
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmeaton committed Jul 25, 2020
1 parent e2128d5 commit e618979
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions scripts/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,41 @@ REPO=${1:-"ktmeaton/plague-phylogeography"}
# Number of uninstall steps
STEPS="5"
# Get plague-phylogeography conda name
PHYLO_CONDA_ENV=`grep "name:" ~/.nextflow/assets/${REPO}/environment.yaml | \
cut -d " " -f 2`
# Use default as backup if not found
PHYLO_CONDA_ENV=${PHYLO_CONDA_ENV:-"plague-phylogeography-0.1.4dev"}
# Get nf-core/eager conda name
EAGER_CONDA_ENV=`grep "name:" ~/.nextflow/assets/nf-core/eager/environment.yaml | \
cut -d " " -f 2`
# Use default as backup if not found
EAGER_CONDA_ENV=${EAGER_CONDA_ENV:-"nf-core-eager-2.2.0dev"}
# Get nextstrain conda name
NEXTSTRAIN_CONDA_ENV=`grep "name:" ~/.nextflow/assets/${REPO}/config/nextstrain.yaml | \
cut -d " " -f 2`
# Use default as backup if not found
NEXTSTRAIN_CONDA_ENV=${NEXTSTRAIN_CONDA_ENV:-"nextstrain-8.0.0"}
PHYLO_CONDA_ENV="plague-phylogeography-0.1.4dev"
if [[ `ls ~/.nextflow/assets/${REPO}/environment.yaml` ]]; then
PHYLO_CONDA_ENV=`grep "name:" ~/.nextflow/assets/${REPO}/environment.yaml | \
cut -d " " -f 2`
fi


# Remove the plague-phylogeography pipeline
# Remove the plague-phylogeography pipeline and conda environment
echo "[1/${STEPS}] Removing the plague-phylogeography nextflow pipeline."
nextflow drop ${REPO}
# Remove the plague-phylogeography conda env
echo "[2/${STEPS}] Removing the plague-phylogeography conda environment."
conda remove -n ${PHYLO_CONDA_ENV} --all
if [[ `ls ~/.nextflow/assets/${REPO}/environment.yaml` ]]; then
PHYLO_CONDA_ENV=`grep "name:" ~/.nextflow/assets/${REPO}/environment.yaml | \
cut -d " " -f 2`
nextflow drop ${REPO}
echo "[2/${STEPS}] Removing the plague-phylogeography conda environment."
conda remove -n ${PHYLO_CONDA_ENV} --all
else
echo "[2/${STEPS}] Removing the plague-phylogeography conda environment...Skip."
fi

# Remove the nfcore/eager pipeline
echo "[3/${STEPS}] Removing the nf-core/eager nextflow pipeline."
nextflow drop nf-core/eager
# Remove the nfcore/eager conda env
echo "[4/${STEPS}] Removing the nf-core/eager conda environment."
conda remove -n ${EAGER_CONDA_ENV} --all
if [[ `ls ~/.nextflow/assets/nf-core/eager/environment.yaml` ]]; then
EAGER_CONDA_ENV=`grep "name:" ~/.nextflow/assets/nf-core/eager/environment.yaml | \
cut -d " " -f 2`
nextflow drop nf-core/eager
echo "[4/${STEPS}] Removing the nf-core/eager conda environment."
conda remove -n ${EAGER_CONDA_ENV} --all
else
echo "[4/${STEPS}] Removing the nf-core/eager conda environment...Skip."
fi

# Remove the nextstrain conda env
echo "[5/${STEPS}] Removing the nextstrain conda environment."
echo "conda remove -n ${NEXTSTRAIN_CONDA_ENV} --all"
conda remove -n ${NEXTSTRAIN_CONDA_ENV} --all
if [[ `ls ~/.nextflow/assets/${REPO}/config/nextstrain.yaml` ]]; then
NEXTSTRAIN_CONDA_ENV=`grep "name:" ~/.nextflow/assets/${REPO}/config/nextstrain.yaml | \
cut -d " " -f 2`
conda remove -n ${NEXTSTRAIN_CONDA_ENV} --all
fi

0 comments on commit e618979

Please sign in to comment.