Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node update bash script (Andrei + Marcelo) #38

Closed
Tracked by #20
gmilescu opened this issue Jan 23, 2024 · 1 comment
Closed
Tracked by #20

Node update bash script (Andrei + Marcelo) #38

gmilescu opened this issue Jan 23, 2024 · 1 comment
Assignees

Comments

@gmilescu
Copy link

No description provided.

@andrei-near
Copy link

andrei-near commented Mar 6, 2024

Code provided to @telezhnaya

#!/bin/bash

# Exit script on first error, treat unset variables as an error, print each command, and return the exit status of the last non-zero command
set -euox pipefail

# Set nearcore repository and Statelessnet branch we're tracking
REPO_NAME="nearcore"
REPO="https://github.com/near/$REPO_NAME.git"
BRANCH="statelessnet_latest"
NEARD_PATH="/home/ubuntu/neard"

# Clone the repository if it doesn't exist
if [ ! -d $REPO_NAME ]; then
    echo "Cloning $REPO into $REPO_NAME"
    git clone $REPO
    cd $REPO_NAME
    git checkout $BRANCH
fi

cd $REPO_NAME
git fetch

# Check if there are any new commits
if [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]; then
    echo "New commit detected. Building..."
    # Pull the latest code
    git pull origin $BRANCH

    # Trigger the build
    cargo build -p neard --bin neard --release --features statelessnet_protocol

    echo "Replacing currently running neard with new binary"
    # Move the binary and make it executable
    mv target/release/neard $NEARD_PATH
    chmod +x $NEARD_PATH

    # Restart neard service
    sudo systemctl restart neard

    echo "Neard binary was updated"
else
    echo "No new commit detected."
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants