Skip to content

Instantly share code, notes, and snippets.

@tka
Last active August 29, 2015 14:26
Show Gist options
  • 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