Skip to content

Commit f87eb0b

Browse files
feat: lodestar script setup (#7254)
* 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 <nflaig@protonmail.com>
1 parent e353f67 commit f87eb0b

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ docs/pages/libraries/lightclient-prover/lightclient.md
5252
docs/pages/libraries/lightclient-prover/prover.md
5353
docs/pages/api/api-reference.md
5454
docs/pages/contribution/getting-started.md
55+
docs/static/install
5556
## Docusaurus
5657
docs/.docusaurus/
5758
docs/build/

docs/pages/run/getting-started/installation.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

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

7+
Run the following command to install the latest version
8+
9+
```bash
10+
curl -fsSL https://chainsafe.github.io/lodestar/install | bash
11+
```
12+
713
## Docker Installation
814

915
The [`chainsafe/lodestar`](https://hub.docker.com/r/chainsafe/lodestar) Docker Hub repository is maintained actively. It contains the `lodestar` CLI preinstalled.

scripts/install-binary.sh

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
3+
# ASCII art
4+
echo " _ _ _ "
5+
echo " | | | | | | "
6+
echo " | | ___ __| | ___ ___| |_ __ _ _ __ "
7+
echo " | |/ _ \ / _ |/ _ \/ __| __/ _ | __|"
8+
echo " | | (_) | (_| | __/\__ \ || (_| | | "
9+
echo " |_|\___/ \__ _|\___||___/\__\__ _|_| "
10+
echo ""
11+
12+
# Declare directories
13+
TEMP_DIR=$(mktemp -d)
14+
LOCAL_BIN="$HOME/.local/bin"
15+
16+
# Ensure ~/.local/bin exists
17+
mkdir -p "$LOCAL_BIN"
18+
19+
# Inform the user about temporary directory usage
20+
echo "Using temporary directory: $TEMP_DIR"
21+
22+
# Fetch the latest release tag from GitHub
23+
echo "Fetching the latest version information..."
24+
VERSION=$(curl -s "https://api.github.com/repos/ChainSafe/lodestar/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
25+
26+
# Check if VERSION is empty
27+
if [ -z "$VERSION" ]; then
28+
echo "Failed to fetch the latest version. Exiting."
29+
exit 1
30+
fi
31+
32+
echo "Latest version detected: $VERSION"
33+
34+
# Detect the operating system and architecture
35+
OS=$(uname -s)
36+
ARCH=$(uname -m)
37+
38+
# Translate architecture to expected format
39+
case $ARCH in
40+
x86_64) ARCH="amd64" ;;
41+
aarch64|arm64) ARCH="arm64" ;;
42+
*)
43+
echo "Unsupported architecture: $ARCH. Exiting."
44+
exit 1
45+
;;
46+
esac
47+
48+
# Translate OS to expected format
49+
case $OS in
50+
Linux) PLATFORM="linux-$ARCH" ;;
51+
*)
52+
echo "Unsupported operating system: $OS. Exiting."
53+
exit 1
54+
;;
55+
esac
56+
57+
# Construct the download URL
58+
URL="https://github.com/ChainSafe/lodestar/releases/download/$VERSION/lodestar-$VERSION-$PLATFORM.tar.gz"
59+
echo "Downloading from: $URL"
60+
61+
# Download the tarball
62+
if ! wget "$URL" -O "$TEMP_DIR/lodestar-$VERSION-$PLATFORM.tar.gz"; then
63+
echo "Download failed. Exiting."
64+
exit 1
65+
fi
66+
67+
# Extract the tarball
68+
echo "Extracting the binary..."
69+
if ! tar -xzf "$TEMP_DIR/lodestar-$VERSION-$PLATFORM.tar.gz" -C "$TEMP_DIR"; then
70+
echo "Extraction failed. Exiting."
71+
exit 1
72+
fi
73+
74+
# Move the binary to ~/.local/bin
75+
echo "Moving the binary to $LOCAL_BIN..."
76+
mv "$TEMP_DIR/lodestar" "$LOCAL_BIN/"
77+
chmod +x "$LOCAL_BIN/lodestar"
78+
79+
# Verify if ~/.local/bin is in PATH
80+
if [[ ":$PATH:" != *":$LOCAL_BIN:"* ]]; then
81+
echo "Adding $LOCAL_BIN to PATH..."
82+
echo 'export PATH="$PATH:$HOME/.local/bin"' >> "$HOME/.bashrc"
83+
echo "Run 'source ~/.bashrc' to apply changes to your shell."
84+
fi
85+
86+
# Clean up the temporary directory
87+
rm -rf "$TEMP_DIR"
88+
89+
# Inform the user of successful installation
90+
echo "Installation complete!"
91+
echo "Run 'lodestar --help' to get started."

scripts/prepare-docs.sh

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ cp -r packages/prover/README.md $DOCS_DIR/pages/libraries/lightclient-prover/pro
1717
# Copy visual assets
1818
rm -rf $DOCS_DIR/pages/assets $DOCS_DIR/pages/images
1919
cp -r $ASSETS_DIR $DOCS_DIR/pages/assets
20+
21+
# Copy binary install script to docs
22+
cp scripts/install-binary.sh $DOCS_DIR/static/install

0 commit comments

Comments
 (0)