-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_install.sh
67 lines (48 loc) · 1.77 KB
/
custom_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#Script executes these commands with some safeguards in place in case it fails:
if [ -z "$1" ]; then
echo "Error: No environment name provided."
echo "Usage: bash $0 <environment_name>"
exit 1
fi
ENV_NAME=$1
echo "Environment specified $ENV_NAME"
# get directory of current script
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR # avoiding small edge case where bashrc sourcing changes your directory
function exit_function() {
echo "To rerun use the command:"
echo "bash -i $SCRIPT_DIR/custom_install.sh $ENV_NAME"
exit 1
}
CONDA_BASE=$(conda info --base)
if [ $? -ne 0 ]; then
echo "Error: Unable to locate Conda installation."
exit_function
fi
source $CONDA_BASE/etc/profile.d/conda.sh
# Check if the environment exists
if ! conda env list | grep -q "$ENV_NAME"; then
echo "Conda environment $ENV_NAME does not exist. Please ensure it is created."
exit 1
fi
CONDA_ENV_PATH=$(conda env list|awk '{print $2}' | grep -v '^$'|grep "$ENV_NAME")
echo "Activating conda environment"
conda activate $ENV_NAME
AMR_DB_UPDATE_SCRIPT="$CONDA_ENV_PATH/bin/amrfinder_update"
echo "update script $AMR_DB_UPDATE_SCRIPT"
$CONDA_ENV_PATH/bin/amrfinder_update -d $CONDA_ENV_PATH/share/amrfinderplus/data
echo "$CONDA_ENV_PATH"
echo "$CONDA_ENV_PATH/share/amrfinderplus/data"
#exit_function
#AMR_DB_PATH = "$CONDA_ENV_PATH/share/amrfinderplus/data"
#echo "update script $AMR_DB_PATH"
#checks if file exist and is executable
if [ ! -x "$AMR_DB_UPDATE_SCRIPT" ]; then
echo "Error: AMR database update script not found at $AMR_DB_UPDATE_SCRIPT."
exit_function
fi
echo "Updating AMR database with $AMR_DB_UPDATE_SCRIPT"
#$AMR_DB_UPDATE_SCRIPT -d $AMR_DB_PATH
echo "Updating AMR database is complete"
echo "Installation complete"