Last active
August 29, 2015 14:26
-
-
Save tka/9af1ca3687fca2f08abc to your computer and use it in GitHub Desktop.
load env var from openssl
This file contains 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
A=123 | |
B=456 | |
C=A1B2C3 | |
FOO=bar |
This file contains 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/bash | |
if vars=$(cat ~/.envs/$1) | |
then | |
echo "Environment Variables Loaded" | |
else | |
# use https://github.com/vim-scripts/openssl.vim | |
if vars=$(cat ~/.envs/$1.aes | openssl aes-256-cbc -d -salt) | |
then | |
echo "Environment Variables Loaded" | |
else | |
echo "Cant Load Environment Variables" | |
exit 1 | |
fi | |
fi | |
while read -r line | |
do | |
key=${line%%=*} | |
val=`echo ${line#*=} | sed 's/^"\|"$//g'` | |
export $key="$val" | |
done <<< "$vars" | |
if [ "${@:2}" ] | |
then | |
echo "run: ${@:2}" | |
bash -c "${@:2}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment