Files
qortal-DevNet-scripts/re-start-devnet-from-node-1.sh
2026-01-20 18:48:51 -08:00

77 lines
2.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# re-start-devnet.sh — Wipe & rebuild your dev-net from mainnet bootstrap
set -euo pipefail
#### CONFIGURE ▶︎ adjust these!
SSH_USER="root" # user for ssh to your other nodes
QORTAL_DIR="/qortal" # where your qortal install lives
REMOTE_NODES=(
"devnet-node-2.example.com"
"devnet-node-3.example.com"
# add more here…
)
BOOTSTRAP_URL="https://bootstrap.qortal.org/bootstrap-archive.7z"
#### PROMPT ▶︎ make sure they really want to do this
read -r -p "⚠️ This will **wipe** the dev-net and re-start it from fresh bootstrap. Continue? (y/N) " RESP
if [[ ! $RESP =~ ^[Yy]$ ]]; then
echo "🛑 Aborted."
exit 1
fi
#### LOGGING ▶︎ tee to console + logfile
LOGFILE="/tmp/re-start-devnet-$(date +%Y%m%d%H%M).log"
exec > >(tee -a "$LOGFILE") 2>&1
echo "=== $(date): Starting re-start-devnet.sh ==="
### helper to run a step and die on failure
run_step() {
local N="$1" DESC="$2"; shift 2
printf "\n→ Step %s: %s\n" "$N" "$DESC"
"$@" # if this fails, set -euo pipefail will exit
}
### 1) Stop Qortal everywhere
run_step 1 "Stopping local Qortal" \
bash -c "cd '$QORTAL_DIR' && ./stop.sh"
for HOST in "${REMOTE_NODES[@]}"; do
run_step "1.$HOST" "Stopping on $HOST" \
ssh -oBatchMode=yes "$SSH_USER@$HOST" \
"cd '$QORTAL_DIR' && ./stop.sh"
done
### 2) Remove old DB locally
run_step 2 "Removing local db" \
bash -c "rm -rf '$QORTAL_DIR/db'"
### 3) Download + extract fresh bootstrap
run_step 3 "Downloading bootstrap" \
wget -q --show-progress -O /tmp/bootstrap.7z "$BOOTSTRAP_URL"
run_step 4 "Extracting bootstrap to local db" \
bash -c "7z x /tmp/bootstrap.7z -o/tmp && mv /tmp/bootstrap '$QORTAL_DIR/db'"
### 4) Push new db to remotes
for HOST in "${REMOTE_NODES[@]}"; do
run_step "4.$HOST" "Cleaning & syncing db to $HOST" \
bash -c "ssh -oBatchMode=yes '$SSH_USER@$HOST' 'rm -rf \"$QORTAL_DIR/db\" && mkdir -p \"$QORTAL_DIR/db\"'" \
&& rsync -aPz --delete "$QORTAL_DIR/db/" \
"$SSH_USER@$HOST:$QORTAL_DIR/db/"
done
### 5) Start local in single-node testnet
run_step 5 "Starting local node (singleNodeTestnet)" \
bash -c "cd '$QORTAL_DIR' && ./start.sh singleNodeTestnet"
### 6) Start all the rest
for HOST in "${REMOTE_NODES[@]}"; do
run_step "6.$HOST" "Starting on $HOST" \
ssh -oBatchMode=yes "$SSH_USER@$HOST" \
"cd '$QORTAL_DIR' && ./start.sh"
done
echo -e "\n=== Done! Check log: $LOGFILE ==="