Skip to content

Instantly share code, notes, and snippets.

@poldz123
Created September 16, 2020 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poldz123/65458cb9bc2c29f92404ccda671d431b to your computer and use it in GitHub Desktop.
Save poldz123/65458cb9bc2c29f92404ccda671d431b to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
createGitlabRunner() {
# Create the tag of this runner based on the number of runners of the machines
GITLAB_TAG="giatec360-shell"
GITLAB_RUNNER_NAME="${1} SHELL"
# Register the runner to gitlab
sudo gitlab-runner register \
--non-interactive \
--name "${GITLAB_RUNNER_NAME}" \
--url "https://gitlab.com/" \
--registration-token "${RUNNER_REGISTRATION_TOKEN}" \
--limit "1" \
--executor "shell" \
--tag-list "${GITLAB_TAG}"
sudo gitlab-runner verify
}
echo ""
read -p "Enter the name of the runner: " RUNNER_NAME
if [[ ! ${RUNNER_NAME} ]]; then
echo ""
echo "ERROR: Invalid name"
echo ""
exit 1
fi
echo ""
read -p "Enter the registration token of the runner: " RUNNER_REGISTRATION_TOKEN
if [[ ! ${RUNNER_REGISTRATION_TOKEN} ]]; then
echo ""
echo "ERROR: Invalid registration token"
echo ""
exit 1
fi
# Set timezone to UTC
sudo timedatectl set-timezone UTC
# Lets clear the old cache
rm -rf /var/cache/gitlab
# Lets clear the runners that was deleted in gitlab
sudo gitlab-runner verify --delete
createGitlabRunner "${RUNNER_NAME}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment