-
Notifications
You must be signed in to change notification settings - Fork 2
/
.envrc
41 lines (34 loc) · 1.45 KB
/
.envrc
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
#!/bin/bash
# ----------------------------------------------------------------------------- #
# The below script reads the .env file and exports the key-value pairs
# Specify the path to your .env file
ENV_FILE=".env"
# Check if the .env file exists
if [ -f "$ENV_FILE" ]; then
echo "[INFO]: Reading $ENV_FILE file."
# Read the .env file line by line
while IFS= read -r line; do
# Skip comments and empty lines
if [[ "$line" =~ ^\s*#.*$ || -z "$line" ]]; then
continue
fi
# Remove leading and trailing whitespaces, and carriage return
CLEANED_LINE=$(echo "$line" | awk '{$1=$1};1' | tr -d '\r')
if [[ $CLEANED_LINE != '#'* ]] && [[ $CLEANED_LINE == *'='* ]]; then
# Add 'export' if not present
if [[ ! $CLEANED_LINE =~ ^export ]]; then
CLEANED_LINE="export $CLEANED_LINE"
fi
# Export the key and value as environment variables
eval $CLEANED_LINE
fi
done < "$ENV_FILE"
echo "[DONE]: Reading $ENV_FILE file."
else
echo "[WARNING]: $ENV_FILE not found."
fi
# ----------------------------------------------------------------------------- #
# export S3_INPUT_PATH="s3://nesta-ds-projects/<MISSION OR PRACTICE>/<PROJECT NAME>"
# Activate the conda environment
eval "$(conda shell.bash activate "asf_hp_installer_chatbot")"
[ "$CONDA_DEFAULT_ENV" = "asf_hp_installer_chatbot" ] || echo "Have you run \`make install\`?"