Make the utxo-set scripts more friendly
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This script shows the steps to download and update an archive of the current UTXO Set
|
# This script shows the steps to download and deploy an archive of the current UTXO Set
|
||||||
|
# It will:
|
||||||
|
# 1. Download the UTXO Set from UTXO_DOWNLOAD_LINK, if UTXO_DOWNLOAD_LINK is empty, use NBITCOIN_NETWORK to find a default
|
||||||
|
# 2. Check the tarball against trusted hashes
|
||||||
|
# 3. Create the container's folders for blocks and chainstate, or empty them if they exists
|
||||||
|
# 4. Unzip the tarball
|
||||||
|
|
||||||
if ! [ "$0" = "$BASH_SOURCE" ]; then
|
if ! [ "$0" = "$BASH_SOURCE" ]; then
|
||||||
echo "This script must not be sourced"
|
echo "This script must not be sourced"
|
||||||
@@ -12,11 +17,20 @@ if [[ $EUID -ne 0 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
: "${UTXO_DOWNLOAD_LINK:=http://utxosets.blob.core.windows.net/public/utxo-snapshot-bitcoin-mainnet-551636.tar}"
|
if [[ "$NBITCOIN_NETWORK" ]]; then
|
||||||
NETWORK=""
|
echo "NBITCOIN_NETWORK should be set to mainnet, testnet or regtest"
|
||||||
[[ $DOWNLOAD_LINK == *-testnet-* ]] && NETWORK="testnet"
|
exit 1
|
||||||
[[ $DOWNLOAD_LINK == *-mainnet-* ]] && NETWORK="mainnet"
|
fi
|
||||||
[[ $DOWNLOAD_LINK == *-regtest-* ]] && NETWORK="regtest"
|
|
||||||
|
if ! [[ "$UTXO_DOWNLOAD_LINK" ]]; then
|
||||||
|
[[ $NBITCOIN_NETWORK == "mainnet" ]] && UTXO_DOWNLOAD_LINK="http://utxosets.blob.core.windows.net/public/utxo-snapshot-bitcoin-mainnet-551636.tar"
|
||||||
|
[[ $NBITCOIN_NETWORK == "testnet" ]] && UTXO_DOWNLOAD_LINK="http://utxosets.blob.core.windows.net/public/utxo-snapshot-bitcoin-testnet-1445586.tar"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ "$UTXO_DOWNLOAD_LINK" ]]; then
|
||||||
|
echo "No default UTXO_DOWNLOAD_LINK for $NBITCOIN_NETWORK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
BITCOIN_DATA_DIR="/var/lib/docker/volumes/generated_bitcoin_datadir/_data"
|
BITCOIN_DATA_DIR="/var/lib/docker/volumes/generated_bitcoin_datadir/_data"
|
||||||
[ ! -d "$BITCOIN_DATA_DIR" ] && mkdir -p "$BITCOIN_DATA_DIR"
|
[ ! -d "$BITCOIN_DATA_DIR" ] && mkdir -p "$BITCOIN_DATA_DIR"
|
||||||
@@ -48,11 +62,11 @@ fi
|
|||||||
rm "sig.asc"
|
rm "sig.asc"
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
NETWORK_DIRECTORY=$NETWORK
|
NETWORK_DIRECTORY=$NBITCOIN_NETWORK
|
||||||
if [[ $NETWORK == "mainnet" ]]; then
|
if [[ $NBITCOIN_NETWORK == "mainnet" ]]; then
|
||||||
NETWORK_DIRECTORY="."
|
NETWORK_DIRECTORY="."
|
||||||
fi
|
fi
|
||||||
if [[ $NETWORK == "testnet" ]]; then
|
if [[ $NBITCOIN_NETWORK == "testnet" ]]; then
|
||||||
NETWORK_DIRECTORY="testnet3"
|
NETWORK_DIRECTORY="testnet3"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# This file is internal and meant to be run by save-utxo-set.sh
|
||||||
BITCOIND="bitcoind -datadir=/data"
|
BITCOIND="bitcoind -datadir=/data"
|
||||||
BITCOIN_CLI="bitcoin-cli -datadir=/data"
|
BITCOIN_CLI="bitcoin-cli -datadir=/data"
|
||||||
|
|
||||||
@@ -26,3 +27,4 @@ TAR_NAME="utxo-snapshot-bitcoin-$NBITCOIN_NETWORK-$PRUNED_HEIGHT.tar"
|
|||||||
echo "Creating $TAR_NAME..."
|
echo "Creating $TAR_NAME..."
|
||||||
tar -cf "$TAR_NAME" "$NETWORK_DIRECTORY/blocks/"
|
tar -cf "$TAR_NAME" "$NETWORK_DIRECTORY/blocks/"
|
||||||
tar -rf "$TAR_NAME" "$NETWORK_DIRECTORY/chainstate/"
|
tar -rf "$TAR_NAME" "$NETWORK_DIRECTORY/chainstate/"
|
||||||
|
exit
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This script shows the steps to create an archive of the current UTXO Set
|
# This script shows the steps to create an archive of the current UTXO Set
|
||||||
|
# It will:
|
||||||
|
# 1. Shutdown BTCPay Server
|
||||||
|
# 2. Start bitcoind
|
||||||
|
# 3. Prune it to up to 289 blocks from the tip
|
||||||
|
# 4. Stop bitcoind
|
||||||
|
# 5. Archive in a tarball the blocks and chainstate directories
|
||||||
|
# 6. Restart BTCPay
|
||||||
|
# 7. If AZURE_STORAGE_CONNECTION_STRING is set, then upload to azure storage and make the blob public, else print hash and tarball
|
||||||
|
|
||||||
: "${AZURE_STORAGE_CONTAINER:=public}"
|
: "${AZURE_STORAGE_CONTAINER:=public}"
|
||||||
|
|
||||||
# IN THE HOST #############################################################
|
|
||||||
|
|
||||||
# Stop btcpay
|
|
||||||
btcpay-down.sh
|
btcpay-down.sh
|
||||||
|
|
||||||
for i in /var/lib/docker/volumes/generated_bitcoin_datadir/_data/utxo-snapshot-*; do
|
for i in /var/lib/docker/volumes/generated_bitcoin_datadir/_data/utxo-snapshot-*; do
|
||||||
|
|||||||
Reference in New Issue
Block a user