From b27981f19412799e47888de5262a4ba7e97e5e01 Mon Sep 17 00:00:00 2001 From: Danny de Kooker Date: Tue, 19 Mar 2024 22:21:23 +0100 Subject: [PATCH] Go install process updated --- .../Linux - Update TRMM agent.sh | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/Supporting_scripts/Linux - Update TRMM agent.sh b/Supporting_scripts/Linux - Update TRMM agent.sh index 962e22d..0d4c0ab 100644 --- a/Supporting_scripts/Linux - Update TRMM agent.sh +++ b/Supporting_scripts/Linux - Update TRMM agent.sh @@ -105,14 +105,46 @@ function go_install() { ;; esac + rm -rvf /usr/local/go/ tar -xvzf /tmp/golang.tar.gz -C /usr/local/ rm /tmp/golang.tar.gz export GOPATH=/usr/local/go export GOCACHE=/root/.cache/go-build - echo "Golang Install Done !" + echo "Go is installed (version $go_current_version)." else - echo "Go is already installed" + # Get the current version of Go installed + go_current_version=$(go version | awk '{print $3}' | sed 's/go//') + + if [ "$go_current_version" != "$go_version" ]; then + echo "Version mismatch. Current installed version is $go_current_version. Desired version is $go_version." + echo "Installing Go $go_version..." + ## Installing golang + case $system in + amd64) + wget -O /tmp/golang.tar.gz $go_url_amd64 + ;; + x86) + wget -O /tmp/golang.tar.gz $go_url_x86 + ;; + arm64) + wget -O /tmp/golang.tar.gz $go_url_arm64 + ;; + armv6) + wget -O /tmp/golang.tar.gz $go_url_armv6 + ;; + esac + + rm -rvf /usr/local/go/ + tar -xvzf /tmp/golang.tar.gz -C /usr/local/ + rm /tmp/golang.tar.gz + export GOPATH=/usr/local/go + export GOCACHE=/root/.cache/go-build + + echo "Go $go_version installed." + else + echo "Go is up to date (version $go_current_version)." + fi fi }