Skip to content

Instantly share code, notes, and snippets.

@bushong1
Created May 27, 2019 13:04
Show Gist options
  • Save bushong1/31971041313cbc64855d38c4d44d8d8a to your computer and use it in GitHub Desktop.
Save bushong1/31971041313cbc64855d38c4d44d8d8a to your computer and use it in GitHub Desktop.
bash essentials
# Check for arbitrary environment variables
UNSET_ENVS=false
function check_env() {
if [ -z "${!1}" ]; then
>&2 echo "ERROR: Environment Variable '$1' is not set"
export UNSET_ENVS=true
else
echo "$1 set to ${!1}"
fi
}
check_env WAIT_FOR_FILE_TO_EXIST_TIMEOUT_SECONDS
check_env SOURCE_FILENAME
check_env TARGET_S3_BUCKET
check_env TARGET_S3_PREFIX
check_env TARGET_S3_FILENAME
if $UNSET_ENVS; then
>&2 echo "FATAL: Correct missing environment variables, then restart container"
exit 1
else
echo All environment variables set correctly
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment