2020-03-11 11:08:20 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
################################################################################
|
|
|
|
|
## File: go.sh
|
|
|
|
|
## Desc: Installs go, configures GOROOT, and adds go to the path
|
|
|
|
|
################################################################################
|
|
|
|
|
|
2020-06-19 19:29:07 +03:00
|
|
|
# Fail out if any setups fail
|
|
|
|
|
set -e
|
2020-03-11 11:08:20 +03:00
|
|
|
|
2020-06-19 19:29:07 +03:00
|
|
|
toolsetJson="$INSTALLER_SCRIPT_FOLDER/toolset.json"
|
|
|
|
|
toolsetVersions=(`ls $AGENT_TOOLSDIRECTORY/go`)
|
|
|
|
|
defaultVersion=$(jq -r '.toolcache[] | select(.name | contains("go")) | .default' $toolsetJson)
|
2020-03-11 11:08:20 +03:00
|
|
|
|
2020-06-19 19:29:07 +03:00
|
|
|
for toolsetVersion in ${toolsetVersions[@]}
|
|
|
|
|
do
|
|
|
|
|
major="$(cut -d'.' -f1 <<< "$toolsetVersion")"
|
|
|
|
|
minor="$(cut -d'.' -f2 <<< "$toolsetVersion")"
|
|
|
|
|
goFolder="$AGENT_TOOLSDIRECTORY/go/$toolsetVersion/x64"
|
2020-05-11 18:26:20 +03:00
|
|
|
|
2020-06-19 19:29:07 +03:00
|
|
|
echo "GOROOT_${major}_${minor}_X64=$goFolder" | tee -a /etc/environment
|
2020-03-11 11:08:20 +03:00
|
|
|
|
2020-06-19 19:29:07 +03:00
|
|
|
if [[ "$toolsetVersion" =~ $defaultVersion ]]; then
|
2020-03-11 11:08:20 +03:00
|
|
|
ln -s $goFolder/bin/* /usr/bin/
|
|
|
|
|
echo "GOROOT=$goFolder" | tee -a /etc/environment
|
|
|
|
|
fi
|
2020-06-19 19:29:07 +03:00
|
|
|
done
|