Skip to content

Instantly share code, notes, and snippets.

@ForboleDevelopment
Last active January 19, 2021 06:58
Show Gist options
  • Save ForboleDevelopment/2d9ebc6e05a4506416cd4a5aab283375 to your computer and use it in GitHub Desktop.
Save ForboleDevelopment/2d9ebc6e05a4506416cd4a5aab283375 to your computer and use it in GitHub Desktop.
Commands that should be run in order to update from morpheus-10000 to morpheus-13000 seamlessly
#!/usr/bin/bash
# This script allows you to setup your node properly getting it
# ready for the Morpheus-13000 update.
# It will checkout and build the propery Desmos version, as well
# as setup your Systemd service.
# The only thing you have to do is run it giving it the first
# argument which is the path where you cloned the Desmos
# repository.
# E.g.
# ./morpheus-13000-update.sh ~/desmos
GO_VERSION=$(go version)
if [[ $GO_VERSION != *"1.15"* ]]; then
echo "Go must be at least 1.15. Please update"
exit
fi
# Get the arguments
DESMOS_PATH=$1
if [ -z "$DESMOS_PATH" ]; then
echo "Specify Desmos installation path using the first argument"
exit
fi
# Create Desmos path if not existing
if [ ! -d "$DESMOS_PATH" ]; then
echo "===> Invalid Desmos folder. Please specify the folder in which you cloned the Desmos repository"
exit
fi
# Stop the currently running node
echo "===> Stopping the node"
sudo systemctl stop desmosd
# Backup the moniker and the priv_validator_key, and delete everything
echo "===> Backing up the data"
MONIKER=$(cat ~/.desmosd/config/config.toml | grep moniker | sed -e 's/moniker = "\(.*\)"/\1/')
if [ -z "$MONIKER" ]; then
MONIKER="moniker"
fi
mv "$HOME/.desmosd/config/priv_validator_key.json" "$HOME/priv_validator_key.json"
rm -r "$HOME/.desmosd"
if [ -d "$HOME/.desmoscli" ]; then
rm -r "$HOME/.desmoscli"
fi
desmosd unsafe-reset-all
# Build Desmos
echo "===> Building the new Desmos version"
cd $DESMOS_PATH
git fetch --tags --force
git checkout tags/v0.15.0
make build
echo "===> Restoring validator data"
desmos init $MONIKER
mv "$HOME/priv_validator_key.json" "$HOME/.desmos/config/priv_validator_key.json"
# Remove the current genesis and get the new one
echo "===> Getting the new genesis"
rm ~/.desmos/config/genesis.json
curl https://raw.githubusercontent.com/desmos-labs/morpheus/master/morpheus-13000/genesis.json > ~/.desmos/config/genesis.json
# Set the seed nodes
echo "===> Updating seed nodes"
sed -i -e 's/seeds = ""/seeds = "cd4612957461881d5f62367c589aaa0fdf933bd8@seed-1.morpheus.desmos.network:26656,fc4714d15629e3b016847c45d5648230a30a50f1@seed-2.morpheus.desmos.network:26656"/g' "$HOME/.desmos/config/config.toml"
# Setup the service file
FILE=/etc/systemd/system/desmosd.service
if test -f "$FILE"; then
echo "===> Setting up the service"
if [ -z "$DAEMON_NAME" ]; then
# The user is NOT using Cosmovisor
mv $DESMOS_PATH/build/desmos* $GOBIN
wget -O ./setup-desmos-service https://gist.githubusercontent.com/ForboleDevelopment/4d9448decf415fd77ef6a40d8e140f2f/raw/455656af0d02e374a8d1636a4a913e8bb935cddd/setup-desmos-service.sh
else
# The user is using Cosmovisor
mkdir -p ~/.desmos/cosmovisor/genesis/bin
mv $DESMOS_PATH/build/desmos* ~/.desmos/cosmovisor/genesis/bin/
wget -O ./setup-desmos-service https://gist.githubusercontent.com/ForboleDevelopment/6eff34282fcef0341376ecf36bb433c2/raw/ce9e1737ab5cc16c15d29f644f9c53b157296c96/setup-desmos-service-cosmovisor.sh
fi
chmod +x ./setup-desmos-service
./setup-desmos-service
fi
# Clean up
echo "===> Removing .desmosd and .desmoscli folders"
rm "$GOBIN/desmosd"
rm "$GOBIN/desmoscli"
# Start service
echo "===> Starting service"
sudo systemctl start desmosd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment