Guest User

Untitled

a guest
Aug 14th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. keychain_location="/path_to/jamf-api.keychain"
  4.  
  5. get_keychain_username() {
  6. # $1 is the path to the keychain
  7. # $2 is the service name
  8. security find-generic-password -s $2 -g $1 2>&1 | grep "acct" | cut -d \" -f 4
  9. }
  10.  
  11. get_keychain_password() {
  12. # $1 is the path to the keychain
  13. # $2 is the service name
  14. security find-generic-password -s $2 -g $1 2>&1 | grep "password" | cut -d \" -f 2
  15. }
  16.  
  17. # unlock the keychain
  18. if [[ ! $JAMF_API_PASS ]]; then
  19. echo "Please run the following command to set the environment variables to unlock the keychain :"
  20. echo
  21. echo ". ./set_credentials.sh"
  22. echo
  23. exit 1
  24. fi
  25. security unlock-keychain -p $JAMF_API_PASS $keychain_location
  26.  
  27. apiuser=$( get_keychain_username $keychain_location apiuser )
  28. apipwd=$( get_keychain_password $keychain_location apiuser )
Add Comment
Please, Sign In to add comment