Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # be sure to load this file with 'source ./filename'
- # project name that uniquely identifies this within your keychain
- project=terraSomething
- ## declare secrets
- declare -a arr=("TF_VAR_username" "TF_VAR_password")
- ## get or prompt each secret
- for i in "${arr[@]}"; do
- # get the password from the keychain
- supersekret=$(security find-generic-password -a "${USER}" -s "secret_${project}_${i}" -w 2>&1)
- # if the security command does not run sucessfully, prompt for secret
- if [ $? -gt 0 ]; then
- echo "What is the secret for ${i}?"
- security add-generic-password -U -a "${USER}" -s "secret_${project}_${i}" -w
- supersekret=$(security find-generic-password -a "${USER}" -s "secret_${project}_${i}" -w)
- fi
- export "${i}=${supersekret}"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement