Last active
April 25, 2023 00:46
-
-
Save calavera/61b92e5d43a58be80c5582cd082e28fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| case $1 in | |
| "store") | |
| in=$(</dev/stdin) | |
| server=$(echo "$in" | jq --raw-output ".ServerURL" | sha1sum - | awk '{print $1}') | |
| username=$(echo "$in" | jq --raw-output ".Username") | |
| password=$(echo "$in" | jq --raw-output ".Secret") | |
| echo "{ \"Username\": \"${username}\", \"Secret\": \"${password}\" }" > $TEMP/$server | |
| ;; | |
| "get") | |
| in=$(</dev/stdin) | |
| server=$(echo "$in" | sha1sum - | awk '{print $1}') | |
| if [[ ! -f $TEMP/$server ]]; then | |
| echo "credentials not found in native keychain" | |
| exit 1 | |
| fi | |
| payload=$(<$TEMP/$server) | |
| echo "$payload" | |
| ;; | |
| "erase") | |
| in=$(</dev/stdin) | |
| server=$(echo "$in" | sha1sum - | awk '{print $1}') | |
| rm -f $TEMP/$server | |
| ;; | |
| *) | |
| echo "unknown credential option" | |
| exit 1 | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment