2021-10-19 19:39:55 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-12-15 10:10:47 +00:00
|
|
|
set -xeuo pipefail
|
2021-10-19 19:39:55 +00:00
|
|
|
|
|
|
|
echo "Running prepare script"
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
2022-06-20 13:31:20 +00:00
|
|
|
export RUNNER_VERSION=2.293.0
|
2021-10-19 19:39:55 +00:00
|
|
|
export RUNNER_HOME=/home/ubuntu/actions-runner
|
|
|
|
|
2021-12-15 10:10:47 +00:00
|
|
|
deb_arch() {
|
|
|
|
case $(uname -m) in
|
|
|
|
x86_64 )
|
|
|
|
echo amd64;;
|
|
|
|
aarch64 )
|
|
|
|
echo arm64;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
runner_arch() {
|
|
|
|
case $(uname -m) in
|
|
|
|
x86_64 )
|
|
|
|
echo x64;;
|
|
|
|
aarch64 )
|
|
|
|
echo arm64;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2021-10-19 19:39:55 +00:00
|
|
|
apt-get update
|
|
|
|
|
|
|
|
apt-get install --yes --no-install-recommends \
|
|
|
|
apt-transport-https \
|
2022-06-20 13:31:20 +00:00
|
|
|
atop \
|
2021-12-23 10:22:08 +00:00
|
|
|
binfmt-support \
|
2021-12-15 10:10:47 +00:00
|
|
|
build-essential \
|
2021-10-19 19:39:55 +00:00
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
gnupg \
|
2021-12-15 10:10:47 +00:00
|
|
|
jq \
|
2021-10-19 19:39:55 +00:00
|
|
|
lsb-release \
|
2021-12-15 10:10:47 +00:00
|
|
|
pigz \
|
|
|
|
python3-dev \
|
2021-10-19 19:39:55 +00:00
|
|
|
python3-pip \
|
2021-12-23 10:22:08 +00:00
|
|
|
qemu-user-static \
|
2021-10-19 19:39:55 +00:00
|
|
|
unzip
|
|
|
|
|
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
|
|
|
2021-12-15 10:10:47 +00:00
|
|
|
echo "deb [arch=$(deb_arch) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
2021-10-19 19:39:55 +00:00
|
|
|
|
|
|
|
apt-get update
|
|
|
|
|
|
|
|
apt-get install --yes --no-install-recommends docker-ce docker-ce-cli containerd.io
|
|
|
|
|
|
|
|
usermod -aG docker ubuntu
|
|
|
|
|
2021-10-22 12:23:41 +00:00
|
|
|
# enable ipv6 in containers (fixed-cidr-v6 is some random network mask)
|
|
|
|
cat <<EOT > /etc/docker/daemon.json
|
|
|
|
{
|
|
|
|
"ipv6": true,
|
2021-12-17 10:20:48 +00:00
|
|
|
"fixed-cidr-v6": "2001:db8:1::/64",
|
2022-06-27 12:44:59 +00:00
|
|
|
"log-driver": "json-file",
|
|
|
|
"log-opts": {
|
|
|
|
"max-file": "5",
|
|
|
|
"max-size": "1000m"
|
|
|
|
},
|
2021-12-17 10:20:48 +00:00
|
|
|
"insecure-registries" : ["dockerhub-proxy.dockerhub-proxy-zone:5000"],
|
|
|
|
"registry-mirrors" : ["http://dockerhub-proxy.dockerhub-proxy-zone:5000"]
|
2021-10-22 12:23:41 +00:00
|
|
|
}
|
|
|
|
EOT
|
|
|
|
|
|
|
|
systemctl restart docker
|
|
|
|
|
2021-12-23 10:22:08 +00:00
|
|
|
# buildx builder is user-specific
|
|
|
|
sudo -u ubuntu docker buildx version
|
|
|
|
sudo -u ubuntu docker buildx create --use --name default-builder
|
|
|
|
|
2021-12-15 10:10:47 +00:00
|
|
|
pip install boto3 pygithub requests urllib3 unidiff dohq-artifactory
|
2021-10-19 19:39:55 +00:00
|
|
|
|
|
|
|
mkdir -p $RUNNER_HOME && cd $RUNNER_HOME
|
|
|
|
|
2021-12-15 10:10:47 +00:00
|
|
|
RUNNER_ARCHIVE="actions-runner-linux-$(runner_arch)-$RUNNER_VERSION.tar.gz"
|
2021-10-19 19:39:55 +00:00
|
|
|
|
2021-12-15 10:10:47 +00:00
|
|
|
curl -O -L "https://github.com/actions/runner/releases/download/v$RUNNER_VERSION/$RUNNER_ARCHIVE"
|
|
|
|
|
|
|
|
tar xzf "./$RUNNER_ARCHIVE"
|
|
|
|
rm -f "./$RUNNER_ARCHIVE"
|
2021-10-19 19:39:55 +00:00
|
|
|
./bin/installdependencies.sh
|
|
|
|
|
|
|
|
chown -R ubuntu:ubuntu $RUNNER_HOME
|
|
|
|
|
|
|
|
cd /home/ubuntu
|
2021-12-15 10:10:47 +00:00
|
|
|
curl "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o "awscliv2.zip"
|
2021-10-19 19:39:55 +00:00
|
|
|
unzip awscliv2.zip
|
|
|
|
./aws/install
|
|
|
|
|
|
|
|
rm -rf /home/ubuntu/awscliv2.zip /home/ubuntu/aws
|
2021-12-15 10:10:47 +00:00
|
|
|
|
|
|
|
# SSH keys of core team
|
|
|
|
mkdir -p /home/ubuntu/.ssh
|
|
|
|
|
|
|
|
# ~/.ssh/authorized_keys is cleaned out, so we use deprecated but working ~/.ssh/authorized_keys2
|
2022-06-27 12:45:50 +00:00
|
|
|
TEAM_KEYS_URL=$(aws ssm get-parameter --region us-east-1 --name team-keys-url --query 'Parameter.Value' --output=text)
|
|
|
|
curl "${TEAM_KEYS_URL}" > /home/ubuntu/.ssh/authorized_keys2
|
2021-12-15 10:10:47 +00:00
|
|
|
chown ubuntu: /home/ubuntu/.ssh -R
|
|
|
|
chmod 0700 /home/ubuntu/.ssh
|
2022-06-20 13:31:20 +00:00
|
|
|
|
|
|
|
# Download cloudwatch agent and install config for it
|
|
|
|
wget --directory-prefix=/tmp https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/"$(deb_arch)"/latest/amazon-cloudwatch-agent.deb{,.sig}
|
|
|
|
gpg --recv-key --keyserver keyserver.ubuntu.com D58167303B789C72
|
|
|
|
gpg --verify /tmp/amazon-cloudwatch-agent.deb.sig
|
|
|
|
dpkg -i /tmp/amazon-cloudwatch-agent.deb
|
|
|
|
aws ssm get-parameter --region us-east-1 --name AmazonCloudWatch-github-runners --query 'Parameter.Value' --output text > /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
|
|
|
|
systemctl enable amazon-cloudwatch-agent.service
|