-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstride-upgrade-v500.sh
More file actions
82 lines (69 loc) · 2.91 KB
/
stride-upgrade-v500.sh
File metadata and controls
82 lines (69 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash -e
# Stride Tendermint upgrade script
# ***ONLY USED IF RUNNING COSMOVISOR. OTHERWISE, NEED TO STOP CHAIN FIRST ***
# =========CONSTANTS===================
# Chain and project constants -- Only need to set once
BINARY_NAME="strided"
COSMOVISOR_BINARY="cosmovisor"
# User home directory. Modify this folder according to your user setup
USER_HOME="/home/user"
# Chain folder on the server
CHAIN_FOLDER="${USER_HOME}/.stride"
# URL of the project's Github repo
GIT_REPO="https://github.com/Stride-Labs/stride/"
# Folder in server where we clone the Github repo
GIT_FOLDER="${USER_HOME}/stride"
# Version upgrade constants -- Change here for each upgrade
# NEW_VERSION is used to download Git release. NEW_VERSION_NAME is used for Cosmovisor upgrade path. Sometimes they're the same, but usually are different.
NEW_VERSION="v5.0.0"
NEW_VERSION_NAME="v5"
# Commit hash is used to match up version release hash. If not matched, script should warn. Logic to be added later
COMMIT_HASH="8848c22076bb51319d4d29d03c772240849092c8"
# Go version prerequisite. If version matched or higher, we won't upgrade Go. Else we upgrade Go. Logic to be added later
GO_DOWNLOAD="go1.19.4.linux-amd64.tar.gz"
# Auto-generated from above constants
UPGRADE_FOLDER="${CHAIN_FOLDER}/cosmovisor/upgrades/${NEW_VERSION_NAME}/bin"
# =========END OF CONSTANTS============
# =========START OF SCRIPT=============
# Check Go download and if it's not blank, then upgrade Go before chain upgrade
echo "Current Go version on server: $(go version)"
if [ -n $GO_DOWNLOAD ]; then
echo "Go version required: ${GO_DOWNLOAD}"
echo "Upgrading Go to new version..."
cd ${USER_HOME}
rm -rf /usr/local/go
wget https://golang.org/dl/${GO_DOWNLOAD}
sudo tar -C /usr/local -xzf ${GO_DOWNLOAD}
echo "Go upgraded!"
fi
# Build the latest version
echo "Building and installing latest version from Github..."
cd ${USER_HOME}
if [ -d "$GIT_FOLDER" ]; then
rm -rf ${GIT_FOLDER}
fi
git clone ${GIT_REPO}
cd ${GIT_FOLDER}
git checkout ${NEW_VERSION}
make install
# Verify version
echo "Verifying version and commit hash..."
${BINARY_NAME} version
NEW_HASH=$(${BINARY_NAME} version --long | grep commit)
echo $NEW_HASH
# Create new cosmovisor upgrade folder and copy new version to it
echo "Creating cosmovisor folder and copying over new version..."
if [ ! -d "$UPGRADE_FOLDER" ]; then
mkdir -p ${UPGRADE_FOLDER}
fi
cp ${USER_HOME}/go/bin/${BINARY_NAME} ${UPGRADE_FOLDER}
echo "Verifying version from cosmovisor upgrade folder..."
${UPGRADE_FOLDER}/${BINARY_NAME} version
# Verifying that cosmovisor is active
IS_ACTIVE=$(systemctl is-active $COSMOVISOR_BINARY)
if [ $IS_ACTIVE == "inactive" ]; then
echo "Cosmovisor is INACTIVE. Make sure to restart it."
elif [ $IS_ACTIVE == "active" ]; then
echo "Cosmovisor is ACTIVE."
fi
echo "Done. If Cosmovisor is active, it will automatically upgrade at preset upgrade height."