Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. # be sure to load this file with 'source ./filename'
  2.  
  3. # project name that uniquely identifies this within your keychain
  4. project=terraSomething
  5.  
  6. ## declare secrets
  7. declare -a arr=("TF_VAR_username" "TF_VAR_password")
  8.  
  9. ## get or prompt each secret
  10. for i in "${arr[@]}"; do
  11. # get the password from the keychain
  12. supersekret=$(security find-generic-password -a "${USER}" -s "secret_${project}_${i}" -w 2>&1)
  13.  
  14. # if the security command does not run sucessfully, prompt for secret
  15. if [ $? -gt 0 ]; then
  16. echo "What is the secret for ${i}?"
  17. security add-generic-password -U -a "${USER}" -s "secret_${project}_${i}" -w
  18. supersekret=$(security find-generic-password -a "${USER}" -s "secret_${project}_${i}" -w)
  19. fi
  20. export "${i}=${supersekret}"
  21. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement