Created
May 27, 2019 13:04
-
-
Save bushong1/31971041313cbc64855d38c4d44d8d8a to your computer and use it in GitHub Desktop.
bash essentials
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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