Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensures the CONFIG_FILE environment variable is set before attempting to use it. #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions scripts/load.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
#!/usr/bin/env bash

FAILURE_COLOR="\033[1;31m"
NO_COLOR="\033[0m"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SUCCESS_COLOR="\033[1;32m"
TEXT_COLOR="\033[1;34m"
NO_COLOR="\033[0m"

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)

if [ -z "$CONFIG_FILE" ]; then
echo -e "${FAILURE_COLOR}CONFIG_FILE is not set. Please set the CONFIG_FILE environment variable.${NO_COLOR}"
exit 1
fi

echo "Config file: $CONFIG_FILE"

echo -e "${TEXT_COLOR}Importing records${NO_COLOR}"
echo -e "${TEXT_COLOR}Importing records...${NO_COLOR}"
/opt/cmr/bin/importer import --config "$CONFIG_FILE"

exit_code=$?
if [ $exit_code -ne 0 ]; then
echo -e "${FAILURE_COLOR}Import failed with code $exit_code"
echo -e "${FAILURE_COLOR}Import failed with code $exit_code${NO_COLOR}"
exit $exit_code
fi

Expand Down