Skip to content

Commit

Permalink
feat: lodestar script setup (#7254)
Browse files Browse the repository at this point in the history
* feat: lodestar_setup

* feat: script_updates + docs

* feat: script_addition_in_docs + command_update

* Remove duplicate script from docs folder

* Minor script updates

* Update script to prepare docs and ignore copied file

* Update installation page

* Wording

---------

Co-authored-by: Nico Flaig <[email protected]>
  • Loading branch information
varunguleriaCodes and nflaig authored Dec 6, 2024
1 parent e353f67 commit f87eb0b
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ docs/pages/libraries/lightclient-prover/lightclient.md
docs/pages/libraries/lightclient-prover/prover.md
docs/pages/api/api-reference.md
docs/pages/contribution/getting-started.md
docs/static/install
## Docusaurus
docs/.docusaurus/
docs/build/
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/run/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

Binaries can be downloaded from the Lodestar [release page](https://github.com/ChainSafe/lodestar/releases/latest) under the `Assets` section.

Run the following command to install the latest version

```bash
curl -fsSL https://chainsafe.github.io/lodestar/install | bash
```

## Docker Installation

The [`chainsafe/lodestar`](https://hub.docker.com/r/chainsafe/lodestar) Docker Hub repository is maintained actively. It contains the `lodestar` CLI preinstalled.
Expand Down
91 changes: 91 additions & 0 deletions scripts/install-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

# ASCII art
echo " _ _ _ "
echo " | | | | | | "
echo " | | ___ __| | ___ ___| |_ __ _ _ __ "
echo " | |/ _ \ / _ |/ _ \/ __| __/ _ | __|"
echo " | | (_) | (_| | __/\__ \ || (_| | | "
echo " |_|\___/ \__ _|\___||___/\__\__ _|_| "
echo ""

# Declare directories
TEMP_DIR=$(mktemp -d)
LOCAL_BIN="$HOME/.local/bin"

# Ensure ~/.local/bin exists
mkdir -p "$LOCAL_BIN"

# Inform the user about temporary directory usage
echo "Using temporary directory: $TEMP_DIR"

# Fetch the latest release tag from GitHub
echo "Fetching the latest version information..."
VERSION=$(curl -s "https://api.github.com/repos/ChainSafe/lodestar/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

# Check if VERSION is empty
if [ -z "$VERSION" ]; then
echo "Failed to fetch the latest version. Exiting."
exit 1
fi

echo "Latest version detected: $VERSION"

# Detect the operating system and architecture
OS=$(uname -s)
ARCH=$(uname -m)

# Translate architecture to expected format
case $ARCH in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*)
echo "Unsupported architecture: $ARCH. Exiting."
exit 1
;;
esac

# Translate OS to expected format
case $OS in
Linux) PLATFORM="linux-$ARCH" ;;
*)
echo "Unsupported operating system: $OS. Exiting."
exit 1
;;
esac

# Construct the download URL
URL="https://github.com/ChainSafe/lodestar/releases/download/$VERSION/lodestar-$VERSION-$PLATFORM.tar.gz"
echo "Downloading from: $URL"

# Download the tarball
if ! wget "$URL" -O "$TEMP_DIR/lodestar-$VERSION-$PLATFORM.tar.gz"; then
echo "Download failed. Exiting."
exit 1
fi

# Extract the tarball
echo "Extracting the binary..."
if ! tar -xzf "$TEMP_DIR/lodestar-$VERSION-$PLATFORM.tar.gz" -C "$TEMP_DIR"; then
echo "Extraction failed. Exiting."
exit 1
fi

# Move the binary to ~/.local/bin
echo "Moving the binary to $LOCAL_BIN..."
mv "$TEMP_DIR/lodestar" "$LOCAL_BIN/"
chmod +x "$LOCAL_BIN/lodestar"

# Verify if ~/.local/bin is in PATH
if [[ ":$PATH:" != *":$LOCAL_BIN:"* ]]; then
echo "Adding $LOCAL_BIN to PATH..."
echo 'export PATH="$PATH:$HOME/.local/bin"' >> "$HOME/.bashrc"
echo "Run 'source ~/.bashrc' to apply changes to your shell."
fi

# Clean up the temporary directory
rm -rf "$TEMP_DIR"

# Inform the user of successful installation
echo "Installation complete!"
echo "Run 'lodestar --help' to get started."
3 changes: 3 additions & 0 deletions scripts/prepare-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ cp -r packages/prover/README.md $DOCS_DIR/pages/libraries/lightclient-prover/pro
# Copy visual assets
rm -rf $DOCS_DIR/pages/assets $DOCS_DIR/pages/images
cp -r $ASSETS_DIR $DOCS_DIR/pages/assets

# Copy binary install script to docs
cp scripts/install-binary.sh $DOCS_DIR/static/install

0 comments on commit f87eb0b

Please sign in to comment.