Meridio: Update to Golang 1.19
[infra/tools.git] / infra / jenkins / slave-setup / nordix-nsm-build-server / configure-image-ubuntu1804.sh
index 76a7e6c10cb5d5fdbf6c3b5dd915cdaad866c095..5eca2cad8f7ee19b907e31c105d16cb0aaf759bf 100644 (file)
@@ -26,12 +26,22 @@ sudo apt update
 sudo apt upgrade -y
 
 # install basic dependencies
-sudo apt install -y make openjdk-11-jre-headless apt-transport-https ca-certificates curl gnupg jq software-properties-common
+sudo apt install -y make openjdk-11-jre-headless apt-transport-https ca-certificates curl gnupg jq software-properties-common build-essential
 
-# set versions of docker-ce, docker-ce-cli, and containerd.io so we know and pin what we use
-DOCKER_CE_VERSION="5:20.10.5~3-0~ubuntu-bionic"
-DOCKER_CE_CLI_VERSION="5:20.10.5~3-0~ubuntu-bionic"
-CONTAINERD_IO_VERSION="1.4.4-1"
+# If you have a issue with Let's Encrypt certificate when cloning repo due to DST Root CA X3 Expiration:
+# https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/
+# remove outdated certificate from system
+sudo rm -rf /usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt
+# update ca-certificates
+sudo update-ca-certificates --fresh --verbose
+
+# set versions of various things for NSM for visibility and ease of maintenance
+DOCKER_CE_VERSION="5:20.10.17~3-0~ubuntu-bionic"
+DOCKER_CE_CLI_VERSION="5:20.10.17~3-0~ubuntu-bionic"
+CONTAINERD_IO_VERSION="1.6.6-1"
+GO_VERSION="1.19"
+GO_LINT_VERSION="1.47.2"
+FOSSA_CLI_VERSION="1.1.7"
 
 # install docker-ce, docker-ce-cli, containerd.io and mark them hold
 sudo apt remove -y docker docker-engine docker.io containerd runc
@@ -44,6 +54,24 @@ sudo apt-mark hold docker-ce docker-ce-cli containerd.io
 sudo systemctl enable docker
 sudo systemctl start docker
 
+# install go related stuff
+cd /tmp
+# golang
+wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz
+tar xzvf go${GO_VERSION}.linux-amd64.tar.gz
+sudo mv go /usr/local
+# golangci-lint
+wget https://github.com/golangci/golangci-lint/releases/download/v${GO_LINT_VERSION}/golangci-lint-${GO_LINT_VERSION}-linux-amd64.deb
+sudo dpkg -i golangci-lint-${GO_LINT_VERSION}-linux-amd64.deb
+/bin/rm -rf  go${GO_VERSION}.linux-amd64.tar.gz golangci-lint-${GO_LINT_VERSION}-linux-amd64.deb
+
+# install fossa-cli
+wget https://github.com/fossas/fossa-cli/releases/download/v${FOSSA_CLI_VERSION}/fossa-cli_${FOSSA_CLI_VERSION}_linux_amd64.tar.gz
+tar xzvf fossa-cli_${FOSSA_CLI_VERSION}_linux_amd64.tar.gz
+sudo mv fossa /usr/local/bin
+sudo chmod +x /usr/local/bin/fossa
+/bin/rm -rf fossa-cli_${FOSSA_CLI_VERSION}_linux_amd64.tar.gz
+
 # Create jenkins user, add it to required groups, configure sudoers and sshd_config
 sudo useradd -G sudo,docker -d /home/jenkins -m -c "jenkins user" -s /bin/bash jenkins
 # Create slave root directory
@@ -59,6 +87,15 @@ sudo bash -c "echo PubkeyAuthentication yes >> /etc/ssh/sshd_config"
 sudo bash -c "echo AllowUsers jenkins >> /etc/ssh/sshd_config"
 sudo systemctl restart sshd
 
+# configure sysctl
+sudo sysctl -w net.ipv4.tcp_keepalive_time=120
+sudo sysctl -w net.ipv4.tcp_keepalive_intvl=30
+sudo sysctl -w net.ipv4.tcp_keepalive_probes=8
+sudo sysctl -w net.ipv4.tcp_fin_timeout=30
+
+# update ~jenkins/.profile
+sudo bash -c "echo 'export PATH=\$PATH:/usr/local/go/bin' >> /home/jenkins/.profile"
+
 # get cloud-init script in place so we can place the keys into ~jenkins/.ssh
 sudo bash -c 'cat << EOF > /var/lib/cloud/scripts/per-instance/copykeystojenkins.sh
 #!/bin/bash