-
-
Notifications
You must be signed in to change notification settings - Fork 313
add setup scrips for mainnet and ordinals server #4136
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
| echo "Starting Bitcoin Core setup..." | ||
|
|
||
| # === Environment Variables === | ||
| export ARCH=x86_64 | ||
| export BITCOIN_VERSION=0.21.1 | ||
| export BITCOIN_URL="https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-${ARCH}-linux-gnu.tar.gz" | ||
| export BITCOIN_DATA_DIR="/blockchain/bitcoin/data" | ||
|
|
||
| # === Create bitcoin user and group === | ||
| echo "Creating bitcoin user and group..." | ||
| sudo groupadd -r bitcoin || true | ||
| sudo useradd -r -m -g bitcoin -s /bin/bash bitcoin || true | ||
|
|
||
| # === Install dependencies === | ||
| echo "Installing dependencies..." | ||
| sudo apt update | ||
| sudo apt install -y ca-certificates gnupg gpg wget jq --no-install-recommends | ||
|
|
||
| # === Download and verify Bitcoin Core === | ||
| echo "Downloading Bitcoin Core..." | ||
| cd /tmp | ||
| wget "https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc" | ||
| wget -qO "bitcoin-${BITCOIN_VERSION}-${ARCH}-linux-gnu.tar.gz" "$BITCOIN_URL" | ||
|
|
||
| # Optional: SHA256 check (manual or via gpg key import step if desired) | ||
| echo "Expected SHA256:" | ||
| cat SHA256SUMS.asc | grep "bitcoin-${BITCOIN_VERSION}-${ARCH}-linux-gnu.tar.gz" | awk '{ print $1 }' | ||
|
|
||
| # === Extract and install Bitcoin Core === | ||
| echo "Installing Bitcoin Core to /opt/bitcoin..." | ||
| sudo mkdir -p "/opt/bitcoin/${BITCOIN_VERSION}" | ||
| sudo mkdir -p "${BITCOIN_DATA_DIR}" | ||
| sudo tar -xzvf "bitcoin-${BITCOIN_VERSION}-${ARCH}-linux-gnu.tar.gz" -C "/opt/bitcoin/${BITCOIN_VERSION}" --strip-components=1 --exclude=*-qt | ||
| sudo ln -sfn "/opt/bitcoin/${BITCOIN_VERSION}" /opt/bitcoin/current | ||
| sudo rm -rf /tmp/* | ||
| sudo chown -R bitcoin:bitcoin "${BITCOIN_DATA_DIR}" | ||
|
|
||
| # === Create bitcoin.conf === | ||
| echo "Creating bitcoin.conf..." | ||
| cat > bitcoin.conf.tmp <<EOF | ||
| datadir=${BITCOIN_DATA_DIR} | ||
| printtoconsole=1 | ||
| rpcallowip=127.0.0.1 | ||
| rpcuser=${BITCOIN_RPC_USER:-bitcoin} | ||
| rpcpassword=${BITCOIN_RPC_PASSWORD:-$(openssl rand -hex 24)} | ||
| testnet=1 | ||
| prune=1000 | ||
| [test] | ||
| rpcbind=127.0.0.1 | ||
| rpcport=18332 | ||
| EOF | ||
|
|
||
| # === Create systemd service === | ||
| echo "Creating systemd service file..." | ||
| cat > bitcoind.service <<EOF | ||
| [Unit] | ||
| Description=Bitcoin Core Testnet | ||
| After=network.target | ||
|
|
||
| [Service] | ||
| User=bitcoin | ||
| Group=bitcoin | ||
| WorkingDirectory=${BITCOIN_DATA_DIR} | ||
| Type=simple | ||
| ExecStart=/opt/bitcoin/current/bin/bitcoind -conf=${BITCOIN_DATA_DIR}/bitcoin.conf | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| EOF | ||
|
|
||
| # === Move config files and set permissions === | ||
| echo "Setting permissions and moving files..." | ||
| sudo mv bitcoin.conf.tmp "${BITCOIN_DATA_DIR}/bitcoin.conf" | ||
| sudo chown bitcoin:bitcoin "${BITCOIN_DATA_DIR}/bitcoin.conf" | ||
| sudo chown -R bitcoin "${BITCOIN_DATA_DIR}" | ||
| sudo ln -sfn "${BITCOIN_DATA_DIR}" /home/bitcoin/.bitcoin | ||
| sudo chown -h bitcoin:bitcoin /home/bitcoin | ||
| sudo chown -R bitcoin:bitcoin /home/bitcoin | ||
|
|
||
| # === Enable and start systemd service === | ||
| echo "Enabling bitcoind systemd service..." | ||
| sudo mv bitcoind.service /etc/systemd/system/bitcoind.service | ||
| sudo systemctl daemon-reload | ||
| sudo systemctl enable bitcoind | ||
| sudo systemctl start bitcoind | ||
|
|
||
| # === Switch to bitcoin user and update PATH === | ||
| echo "Appending Bitcoin Core to PATH for bitcoin user..." | ||
| sudo su - bitcoin -c 'echo "export PATH=\$PATH:/opt/bitcoin/current/bin" >> ~/.profile' | ||
|
|
||
| echo "Bitcoin Core setup complete!" | ||
| echo "Use 'sudo su - bitcoin' then run 'bitcoin-cli -getinfo' to check sync status." | ||
| echo "Or run 'sudo journalctl -fu bitcoind' as root to monitor logs." | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/bin/bash | ||
|
|
||
krrish-sehgal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Step 1: Update system packages | ||
| echo "Updating system packages..." | ||
| sudo apt update && sudo apt upgrade -y | ||
|
|
||
| # Step 2: Install required dependencies | ||
| echo "Installing dependencies..." | ||
| sudo apt install -y curl git build-essential libssl-dev pkg-config | ||
|
|
||
| # Step 3: Install Rust | ||
| echo "Installing Rust..." | ||
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
| source "$HOME/.cargo/env" | ||
|
|
||
| # Step 4: Check Rust versions | ||
| rustc --version | ||
| cargo --version | ||
|
|
||
| # Step 5: Download and extract ord source code | ||
| echo "Downloading ord 0.22.2..." | ||
| wget https://github.com/ordinals/ord/archive/refs/tags/0.22.2.tar.gz | ||
| tar -xvzf 0.22.2.tar.gz | ||
| cd ord-0.22.2 | ||
|
|
||
| # Step 6: Install build tools (again, just in case) | ||
| echo "Installing build tools for compiling ord..." | ||
| sudo apt update | ||
| sudo apt install -y build-essential clang cmake gcc g++ make pkg-config libssl-dev | ||
|
|
||
| # Step 7: Build ord from source | ||
| echo "Building ord..." | ||
| cargo build --release | ||
|
|
||
| # Step 8: Move the binary to /usr/local/bin | ||
| echo "Moving ord binary to /usr/local/bin..." | ||
| sudo mv target/release/ord /usr/local/bin/ | ||
|
|
||
| # Step 9: Verify ord installation | ||
| ord --version | ||
|
|
||
| # Optional: Get the index | ||
| echo "Downloading index file..." | ||
| sudo apt update && sudo apt install transmission-cli -y | ||
| transmission-cli "https://ordstuff.info/indexes/0.22/index-0.22-without-878500.redb.gz.torrent" | ||
|
|
||
| # Wait for download to complete manually before continuing | ||
|
|
||
| # Optional: Decompress the index file | ||
| echo "Installing pv for decompression progress..." | ||
| sudo apt install -y pv | ||
| pv index-0.22-without-878500.redb.gz | gunzip > index-0.22-without-878500.redb | ||
|
|
||
| echo "Setup complete!" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.