Last active
December 24, 2018 17:47
-
-
Save noqcks/a0b8a1ed5f37313d151fb3de2b738630 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
set -eo pipefail | |
# get ejson2env | |
wget -q https://gist.github.com/noqcks/88304840eb85e6d7ac6d3dcfe1fa9bc4/raw/e8d7beaa89ec8a819489852d023dc641b027748c/ejson2env | |
chmod +x ejson2env | |
mv ejson2env /usr/bin/ejson2env | |
# exit if $ENV doesn't exist. Not sure what environment to decrypt! | |
if [[ -z "${ENV}" ]]; then | |
echo -e "\033[1;33m WARN: >>> SKIPPING EJSON DECRYPT <<< \033[0m" | |
echo -e "\033[1;33m WARN: ejson not decoded. You haven't specified "\$ENV", so ejson doesn't know what environment to decrypt. \033[0m" | |
echo -e "\033[1;30m INFO: ejson looks for secrets at /opt/secrets/\$ENV.ejson \033[0m" | |
exit 0 | |
fi | |
# exit if secret not at specified location. | |
if [ ! -f /opt/secrets/$ENV.ejson ]; then | |
echo -e "\033[1;33m WARN: >>> SKIPPING EJSON DECRYPT <<< \033[0m" | |
echo -e "\033[1;33m WARN: ejson not decoded. Secrets do not exist at the specified location: /opt/secrets/$ENV.ejson \033[0m" | |
exit 0 | |
fi | |
# bring secrets into environment | |
eval $(ejson2env /opt/secrets/$ENV.ejson) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment