Created
April 24, 2018 12:08
-
-
Save njdancer/ef8187d40600f571855c35ebb547721a to your computer and use it in GitHub Desktop.
This file contains 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 | |
SSH_DIR=$(getent passwd $1 | cut -d: -f6)/.ssh | |
KEY_LOC=$SSH_DIR/keyLocation | |
CACHE=$KEY_LOC.cache | |
AUTH_KEYS="" | |
if [ -e "$KEY_LOC" ] | |
then | |
while read URL | |
do | |
if [ ! -z "$URL" ] | |
then | |
KEY=$(curl -sf "$URL") | |
CURL_EXIT_STATUS=$? | |
if [ $CURL_EXIT_STATUS != 0 ] | |
then | |
cat $CACHE | |
exit $? | |
fi | |
AUTH_KEYS+=$(curl -sf "$URL")$'\n' | |
fi | |
done <$KEY_LOC | |
fi | |
if [ ! -z "$AUTH_KEYS" ] | |
then | |
printf "$AUTH_KEYS" > "$CACHE" | |
printf "$AUTH_KEYS" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment