Last active
March 13, 2020 16:30
-
-
Save euyuil/adff2508048894286410b42004bd7538 to your computer and use it in GitHub Desktop.
Setup script for GitLab Runner and other tools with China mirrors
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 | |
# OS: Ubuntu 18.04 | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
# Reference: https://mirror.tuna.tsinghua.edu.cn/help/gitlab-runner/ | |
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null | |
sudo echo 'deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/ubuntu bionic main' > /etc/apt/sources.list.d/gitlab-runner.list | |
sudo apt-get update | |
sudo apt-get install -y gitlab-runner | |
# Reference: https://mirror.tuna.tsinghua.edu.cn/help/docker-ce/ | |
sudo snap remove docker | |
sudo apt-get remove -y docker docker-engine docker.io | |
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository \ | |
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
sudo apt-get update | |
sudo apt-get install -y docker-ce | |
# Reference: https://docs.docker.com/compose/install/ | |
sudo curl -L "https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
# Reference: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-ubuntu-1804 | |
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O /tmp/packages-microsoft-prod.deb | |
sudo dpkg -i /tmp/packages-microsoft-prod.deb | |
sudo add-apt-repository universe | |
sudo apt-get update | |
sudo apt-get install -y apt-transport-https | |
sudo apt-get update | |
sudo apt-get install -y dotnet-sdk-3.1 | |
# Post-installation configuration | |
sudo usermod -aG docker gitlab-runner | |
sudo gitlab-runner register | |
# Reference: https://www.cnblogs.com/cmt/p/nuget-mirror.html | |
# Reference: https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior | |
mkdir -p /var/lib/gitlab-runner/.nuget/NuGet | |
cat > /var/lib/gitlab-runner/.nuget/NuGet/NuGet.Config << EOF | |
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<packageSources> | |
<add key="nuget.cnblogs.com" value="https://nuget.cnblogs.com/v3/index.json" protocolVersion="3" /> | |
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | |
</packageSources> | |
<packageRestore> | |
<add key="enabled" value="True" /> | |
<add key="automatic" value="True" /> | |
</packageRestore> | |
<bindingRedirects> | |
<add key="skip" value="False" /> | |
</bindingRedirects> | |
</configuration> | |
EOF | |
chown -R gitlab-runner:gitlab-runner /var/lib/gitlab-runner/.nuget/NuGet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment