Skip to content

Instantly share code, notes, and snippets.

@tka
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tka/9af1ca3687fca2f08abc to your computer and use it in GitHub Desktop.
Save tka/9af1ca3687fca2f08abc to your computer and use it in GitHub Desktop.
load env var from openssl
A=123
B=456
C=A1B2C3
FOO=bar
#!/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