automate/get-gitlab_runner.sh

35 lines
1.6 KiB
Bash

GITLAB_URL="git.ring-zero.co.uk"
#GITLAB_URL="192.168.1.195" # 192.168.1.48
GITLAB_PORT="443" # 10022:22 32768:443 10080:80
#GITLAB_PORT="32768" # 10022:22 32768:443 10080:80
#GITLAB_PORT="10080" # 10022:22 32768:443 10080:80
#GITLAB_PORT="10022" # 10022:22 32768:443 10080:80
GITLAB_USER="cyteen"
#PROTO="https" # http
PROTO="http" # http
CURL_OPTIONS="--insecure"
PRIVATE_TOKEN="P8mHeR6ASfAsHeqQKdvg" # ${PROTO}://${GITLAB_URL}/profile/personal_access_tokens //*[@id="feed_token"]
RSA_KEY=$(cat ${HOME}/.ssh/id_rsa.pub)
curl ${CURL_OPTIONS} --header "PRIVATE-TOKEN ${PRIVATE_TOKEN}" "${PROTO}://${GITLAB_URL}/api/v4/runners"
## Send
#echo ""
#echo "Sending key."
#echo "COMMAND: curl ${CURL_OPTIONS} -d '{"title":"test key","key":"'"${RSA_KEY}"'"}' -H 'Content-Type: application/json' ${PROTO}://${GITLAB_URL}:${GITLAB_PORT}/api/v4/user/keys?private_token=${PRIVATE_TOKEN}"
#curl ${CURL_OPTIONS} -d '{"title":"test key","key":"'"${RSA_KEY}"'"}' -H 'Content-Type: application/json' ${PROTO}://${GITLAB_URL}:${GITLAB_PORT}/api/v4/user/keys?private_token=${PRIVATE_TOKEN}
#
## {"id":3889765,"title":"test key","key":"ssh-rsa <my_ssh_key>","created_at":"2019-08-01T21:26:40.952Z"}
#
#
## Test
#echo ""
#echo "Testing key."
#echo "COMMAND: curl ${CURL_OPTIONS} ${PROTO}://${GITLAB_URL}:${GITLAB_PORT}/api/v4/user/keys?private_token=${PRIVATE_TOKEN}"
#curl ${CURL_OPTIONS} ${PROTO}://${GITLAB_URL}:${GITLAB_PORT}/api/v4/user/keys?private_token=${PRIVATE_TOKEN}
#
# [{"id":3889765,"title":"test key","key":"ssh-rsa <my_ssh_key>","created_at":"2019-08-01T21:26:40.952Z"}]