init setup

This commit is contained in:
mhatal
2025-02-07 00:41:19 -06:00
commit 57c76b8973
5 changed files with 93 additions and 0 deletions

11
.envrc Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
PATH_add ./bin
export ORD_VERSION=0.22.2
export BITCOIN_RPC_URL=http://bitcoin.mainnet.stacks.org
export BITCOIN_RPC_USERNAME=stacks
export BITCOIN_RPC_PASSWORD=foundation
if [ -f "$PWD/.envrc.override" ]; then
source_env "$PWD/.envrc.override"
fi

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/data
/.envrc.*

60
backup.sh Normal file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd $DIR
REPO=alexgo-io/ord-mainnet
RELEASE_DIR=$DIR/data/gh-release
rm -rf $RELEASE_DIR
mkdir -p $RELEASE_DIR
curl -s -H "Accept: application/json" http://127.0.0.1:3588/status | jq > $RELEASE_DIR/status.json
export BLOCK=$(cat $RELEASE_DIR/status.json | jq .height)
if [ -z "$BLOCK" ]; then
echo "Failed to get block height, aborted."
exit -1
fi
echo "Starting backup at block height $BLOCK"
date
docker compose down
export ZSTD_NBTHREADS=8
export ZSTD_CLEVEL=9
pushd data &> /dev/null
bash -c "tar -I zstd -Ocvp index | split -b 2000M -d - $RELEASE_DIR/index.tar.zstd."
popd &> /dev/null
docker compose up -d
cd $RELEASE_DIR
echo "Block height: $BLOCK" > NOTES.md
echo >> NOTES.md
echo "To restore from this backup, run the following scripts:" >> NOTES.md
echo >> NOTES.md
echo '```bash
bash -c '"'" >> NOTES.md
ls index.tar.zstd.* | sort | while read FILE; do
echo "curl -L https://github.com/$REPO/releases/download/block-$BLOCK/$FILE && \\" >> NOTES.md
done
echo 'true'"'"' | tar -I zstd -xvp -C data
```' >> NOTES.md
gh release -R $REPO create block-$BLOCK -t "Block $BLOCK Snapshot" --draft --notes-file NOTES.md
gh release -R $REPO upload block-$BLOCK *.json
ls index.tar.zstd.* | sort | while read FILE; do
gh release -R $REPO upload block-$BLOCK $FILE &
done
wait
gh release -R $REPO edit block-$BLOCK --draft=false --latest
# cleanup old releases
TOTAL=$(gh release -R $REPO ls | wc -l)
TO_DEL=$(($TOTAL - 16))
if [ $TO_DEL -gt 0 ]; then
echo cleanup $TO_DEL releases
gh release -R $REPO ls | grep 'block-' | grep -v latest | tail -${TO_DEL} | awk '{print $(NF-1)}' | while read tag; do
gh release -R $REPO delete -y --cleanup-tag $tag
done
fi
date

10
docker-compose.yml Normal file
View File

@@ -0,0 +1,10 @@
services:
ord:
image: ubuntu:24.04
container_name: ord
network_mode: host
restart: always
command: ord --chain mainnet --config-dir /var/lib/ord --datadir /var/lib/ord --index-addresses --index-runes --index-sats --commit-interval 100 --bitcoin-rpc-url ${BITCOIN_RPC_URL} --bitcoin-rpc-username ${BITCOIN_RPC_USERNAME} --bitcoin-rpc-password ${BITCOIN_RPC_PASSWORD} server --http --http-port ${ORD_PORT}
volumes:
- $PWD/data/ord-${ORD_VERSION}:/usr/local/bin:ro
- $PWD/data/index:/var/lib/ord

10
setup.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd $DIR
mkdir -p data
pushd data &> /dev/null
rm -rf ord-*
curl -sSL https://github.com/ordinals/ord/releases/download/${ORD_VERSION}/ord-${ORD_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xzf -
popd &> /dev/null