Last active
January 13, 2023 06:29
-
-
Save kwunyeung/802965472b526513f12793eeaef5abd2 to your computer and use it in GitHub Desktop.
script to upgrade the Cosmos gaia testnet
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 | |
# Upgrade Cosmos SDK and restart gaiad | |
POSITIONAL=() | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-t|--tag) | |
TAG="$2" | |
shift # past argument | |
shift # past value | |
;; | |
--default) | |
DEFAULT=YES | |
shift # past argument | |
;; | |
*) # unknown option | |
POSITIONAL+=("$1") # save it in an array for later | |
shift # past argument | |
;; | |
esac | |
done | |
set -- "${POSITIONAL[@]}" # restore positional parameters | |
if [ -z "$TAG" ]; then | |
echo "Usage: gaia_upgrade.sh -t v0.19.0" | |
exit 1 | |
fi | |
export GOPATH=$HOME/go | |
export PATH=$GOPATH/bin:$PATH | |
# upgarde system packages | |
sudo apt upgrade -y | |
# install dep and statik | |
sudo apt install go-dep golang-statik -y | |
# get latest Cosmos SDK | |
go get github.com/cosmos/cosmos-sdk | |
cd $GOPATH/src/github.com/cosmos/cosmos-sdk | |
git fetch --all | |
git checkout -f $TAG | |
make clean && make install | |
echo "" | |
echo "Cosmos SDK " $TAG "installed." | |
echo "" | |
# Log installed versions | |
echo "gaiad version :" $(gaiad version) | |
echo "gaiacli version :" $(gaiacli version) | |
cd | |
echo "Stopping gaiad" | |
sudo service gaiad stop | |
sudo cp go/bin/gaia* /opt/go/bin/ | |
echo "Starting gaiad" | |
sudo service gaiad start | |
echo "gaiad restarted." | |
Line 28 is only an example of the usage of this script. build-essential
only need to install if gcc
is not available. It should not be in the upgrade script.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A couple updates -
Update line 28 to v0.21.0
To fix -
make install error
"
make install
go install -tags netgo -ldflags “-X github.com/cosmos/cosmos-sdk/version.GitCommit=06216c1” ./cmd/gaia/cmd/gaiad
#- github.com/cosmos/cosmos-sdk/vendor/github.com/brejski/hid
exec: “gcc”: executable file not found in $PATH
Makefile:40: recipe for target ‘install’ failed
make: *** [install] Error 2
"
just need
apt-get install build-essential
then run
make install