WIP
Last active
November 18, 2020 21:42
-
-
Save jose-mdz/050f8ff5385669448509411dd67c1085 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 | |
# | |
# IMPORTANT: Make sure GIT_AUTH is present before running this script. | |
# | |
if [[ -z ${GIT_AUTH} ]]; then | |
echo "The variable GIT_AUTH is not present." | |
exit 1 | |
fi | |
if [[ -z ${GIT_ACC} ]]; then | |
echo "The variable GIT_ACC is not present." | |
exit 1 | |
fi | |
# | |
# Disable StrictHostKeyChecking for Github (Avoids the yes/no question) | |
echo "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config && \ | |
# | |
# | |
# Create identity | |
ssh-keygen -t rsa -b 4096 -C "`uname -n`" -q -N "" -f ~/.ssh/id_rsa && \ | |
# | |
# | |
# Read public key | |
RSA_PUB=`cat ~/.ssh/id_rsa.pub | awk '{print $1, $2;}'` && \ | |
# | |
# | |
# Read name of pod for title | |
SSH_TITLE=`uname -n` && \ | |
# | |
# | |
# Call to register public key | |
curl -X POST \ | |
https://api.github.com/user/keys \ | |
-H "Authorization: Basic ${GIT_AUTH}" \ | |
-H 'Content-Type: text/plain' \ | |
-d "{\"title\":\"${SSH_TITLE}\",\"key\":\"${RSA_PUB}\"}" && \ | |
# | |
# | |
# Clone this repo | |
git clone [email protected]:${GIT_ACC}/infra-grid-server.git && \ | |
# | |
# | |
# Run setup script | |
./infra-grid-server/setup.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment