Last active
May 31, 2022 18:30
-
-
Save mavjs/d6e8cc5f16cd8f55b62595e5e0723b6c to your computer and use it in GitHub Desktop.
Revisions
-
mavjs revised this gist
May 31, 2022 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -38,6 +38,7 @@ FILE_URL="${DL_URL}${LATEST_FILE}" CHECKSUM_URL="${FILE_URL}.sha256" CHECKSUM_FILE="${LATEST_FILE}.sha256sum" echo "Downloading: ${FILE_URL} at ${LATEST_FILE}" curl -L -s -o "${LATEST_FILE}" "${FILE_URL}" echo "Downloading checksum: ${CHECKSUM_URL} at ${CHECKSUM_FILE}" @@ -47,7 +48,7 @@ echo "${CHECKSUM}" "${LATEST_FILE}" > "${CHECKSUM_FILE}" echo "Checking hashsum ....." STATUS=$(sha256sum -c "${LATEST_FILE}.sha256sum" | grep OK) if [ -n "${STATUS}" ]; then echo "Hashsum is good!" else echo "HASHSUM IS NOT GOOD!" @@ -57,13 +58,18 @@ fi echo "Installing....." if [ -d "/home/${USER}/goroot" ]; then echo "Removing goroot before upgrade" rm -rf "/home/${USER}/goroot" mkdir "/home/${USER}/goroot/" echo "Installing in ~/goroot" tar -C "/home/${USER}/goroot" -xzf "${LATEST_FILE}" --strip-components=1 else echo "Removing goroot before upgrade" rm -rf "/usr/local/go" echo "Installing /usr/local/" tar -C "/usr/local/" -xzf "${LATEST_FILE}" fi echo "Cleaning up temp directory at: ${FILE_DIR}" rm -rf "${FILE_DIR}" ``` -
mavjs revised this gist
May 31, 2022 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,6 @@ FILE_URL="${DL_URL}${LATEST_FILE}" CHECKSUM_URL="${FILE_URL}.sha256" CHECKSUM_FILE="${LATEST_FILE}.sha256sum" echo "Downloading: ${FILE_URL} at ${LATEST_FILE}" curl -L -s -o "${LATEST_FILE}" "${FILE_URL}" echo "Downloading checksum: ${CHECKSUM_URL} at ${CHECKSUM_FILE}" -
mavjs revised this gist
May 31, 2022 . 1 changed file with 22 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,39 +12,47 @@ tar -C ~/goroot -xzvf go$VERSION.linux-amd64.tar.gz --strip-components=1 # set -e set -o pipefail FILE_DIR=$(mktemp -d -t upgover-XXXXXXXX) echo "Entering into temporary work directory: ${FILE_DIR}" cd "${FILE_DIR}" || exit URL="https://golang.org" VER_CHECK="${URL}/dl/" DL_URL="https://dl.google.com/go/" LATEST_FILE=$(curl -L -s "${VER_CHECK}" | grep filename | grep download | grep linux-amd64.tar.gz | head -n 1 | cut -d">" -f 3 | cut -d"<" -f 1) echo "Latest file: ${LATEST_FILE}" VER=$(echo "${LATEST_FILE}" | grep -oP 'go[0-9\.]+') LATEST_VER=${VER%?} CUR_VER=$(go version | cut -d" " -f3) if [ "${LATEST_VER}" == "${CUR_VER}" ]; then echo "You are already on the latest golang version: ${CUR_VER}" exit 1 fi FILE_URL="${DL_URL}${LATEST_FILE}" CHECKSUM_URL="${FILE_URL}.sha256" CHECKSUM_FILE="${LATEST_FILE}.sha256sum" echo "Downloading: ${FILE_URL} at ${LATEST_FILE}" curl -L -s -o "${LATEST_FILE}" "${FILE_URL}" echo "Downloading checksum: ${CHECKSUM_URL} at ${CHECKSUM_FILE}" CHECKSUM=$(curl -s "${CHECKSUM_URL}") echo "${CHECKSUM}" "${LATEST_FILE}" > "${CHECKSUM_FILE}" echo "Checking hashsum ....." STATUS=$(sha256sum -c "${LATEST_FILE}.sha256sum" | grep OK) if [ -n "${STATUS}" ]; then echo "Hashsum is good!" else echo "HASHSUM IS NOT GOOD!" exit 1 fi echo "Installing....." @@ -54,6 +62,7 @@ then tar -C "/home/${USER}/goroot" -xzf "${LATEST_FILE}" --strip-components=1 else echo "Installing /usr/local/" tar -C "/usr/local/" -xzf "${LATEST_FILE}" fi echo "Cleaning up temp directory at: ${FILE_DIR}" -
mavjs revised this gist
Sep 16, 2020 . 1 changed file with 54 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,58 @@ By default the go tar file will unpack with `go/` as a prefix directory, thus we ```bash tar -C ~/goroot -xzvf go$VERSION.linux-amd64.tar.gz --strip-components=1 ``` ## Script to update ```bash #!/bin/bash # set -e set -o pipefail URL="https://golang.org" VER_CHECK="${URL}/dl/" DL_URL="https://dl.google.com/go/" LATEST_FILE=$(curl -s "${VER_CHECK}" | grep filename | grep download | grep linux-amd64.tar.gz | head -n 1 | cut -d">" -f 3 | cut -d"<" -f 1) VER=$(echo "${LATEST_FILE}" | grep -oP 'go[0-9\.]+') LATEST_VER=${VER%?} CUR_VER=$(go version | cut -d" " -f3) if [ "${LATEST_VER}" == "${CUR_VER}" ]; then echo "You're on the latest golang version: ${CUR_VER}" exit fi FILE_URL="${DL_URL}${LATEST_FILE}" CHECKSUM_URL="${FILE_URL}.sha256" FILE_DIR=$(mktemp -d -t upgover-XXXXXXXX) echo "Downloading: ${FILE_URL} at ${FILE_DIR}/${LATEST_FILE}" echo "Downloading checksum: ${CHECKSUM_URL} at ${FILE_DIR}/${LATEST_FILE}.sha256" curl -s -o "${FILE_DIR}/${LATEST_FILE}" "${FILE_URL}" CHECKSUM=$(curl -s "${CHECKSUM_URL}") pushd "${FILE_DIR}" || exit STATUS=$(echo "${CHECKSUM} ${LATEST_FILE}" | sha256sum -c | grep OK) if [ -n "${STATUS}" ]; then echo "Pretty ok!" else echo "NOT OK!" fi echo "Installing....." if [ -d "/home/${USER}/goroot" ]; then echo "Installing in ~/goroot" tar -C "/home/${USER}/goroot" -xzf "${LATEST_FILE}" --strip-components=1 else echo "Installing /usr/local/" fi echo "Cleaning up temp directory at: ${FILE_DIR}" rm -rf "${FILE_DIR}" ``` -
mavjs created this gist
May 31, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ # About If your `$GOROOT` is in `~/goroot` and your `$GOPATH` is in `~/go`, you want to make sure that your new go version goes to the right folder. By default the go tar file will unpack with `go/` as a prefix directory, thus we want to remove that when unpacking, thus the `--strip-components=1`. ```bash tar -C ~/goroot -xzvf go$VERSION.linux-amd64.tar.gz --strip-components=1 ```