Files
aitbc/scripts/workflow/02_genesis_authority_setup.sh
aitbc1 19fccc4fdc
All checks were successful
Documentation Validation / validate-docs (push) Successful in 9s
refactor: extract script snippets to reusable scripts
- Create modular scripts for multi-node blockchain setup
- Extract 6 core setup scripts from workflow documentation
- Add master orchestrator script for complete setup
- Replace inline code with script references in workflow
- Create comprehensive README for script documentation
- Copy scripts to aitbc for cross-node execution
- Improve maintainability and reusability of setup process

Scripts created:
- 01_preflight_setup.sh - System preparation
- 02_genesis_authority_setup.sh - Genesis node setup
- 03_follower_node_setup.sh - Follower node setup
- 04_create_wallet.sh - Wallet creation
- 05_send_transaction.sh - Transaction sending
- 06_final_verification.sh - System verification
- setup_multinode_blockchain.sh - Master orchestrator

This makes the workflow cleaner and scripts reusable
while maintaining all functionality.
2026-03-29 16:08:42 +02:00

78 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
# Genesis Authority Setup Script for AITBC Node (aitbc1)
# This script configures aitbc1 as the genesis authority node
set -e # Exit on any error
echo "=== AITBC Genesis Authority Setup (aitbc1) ==="
# We are already on aitbc1 node (localhost)
# No SSH needed - running locally
# Pull latest code
echo "1. Pulling latest code..."
cd /opt/aitbc
git pull origin main
# Install/update dependencies
echo "2. Installing/updating dependencies..."
/opt/aitbc/venv/bin/pip install -r requirements.txt
# Check and create required directories if they don't exist
echo "3. Creating required directories..."
mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc
# Verify directories exist
ls -la /var/lib/aitbc/ || echo "Creating /var/lib/aitbc/ structure..."
# Copy and adapt central .env for aitbc1 (genesis authority)
cp /etc/aitbc/blockchain.env /etc/aitbc/blockchain.env.aitbc1.backup 2>/dev/null || true
# Update .env for aitbc1 genesis authority configuration
echo "4. Updating environment configuration..."
sed -i 's|proposer_id=.*|proposer_id=aitbc1genesis|g' /etc/aitbc/.env
sed -i 's|keystore_path=/opt/aitbc/apps/blockchain-node/keystore|keystore_path=/var/lib/aitbc/keystore|g' /etc/aitbc/.env
sed -i 's|keystore_password_file=/opt/aitbc/apps/blockchain-node/keystore/.password|keystore_password_file=/var/lib/aitbc/keystore/.password|g' /etc/aitbc/.env
sed -i 's|db_path=./data/ait-mainnet/chain.db|db_path=/var/lib/aitbc/data/ait-mainnet/chain.db|g' /etc/aitbc/.env
sed -i 's|enable_block_production=true|enable_block_production=true|g' /etc/aitbc/.env
sed -i 's|gossip_broadcast_url=redis://127.0.0.1:6379|gossip_broadcast_url=redis://localhost:6379|g' /etc/aitbc/.env
sed -i 's|p2p_bind_port=8005|p2p_bind_port=7070|g' /etc/aitbc/.env
# Add trusted proposers for follower nodes
echo "trusted_proposers=aitbc1genesis" >> /etc/aitbc/.env
# Create genesis block with wallets (using Python script until CLI is fully implemented)
echo "5. Creating genesis block with wallets..."
cd /opt/aitbc/apps/blockchain-node
/opt/aitbc/venv/bin/python scripts/setup_production.py \
--base-dir /opt/aitbc/apps/blockchain-node \
--chain-id ait-mainnet \
--total-supply 1000000000
# Get actual genesis wallet address and update config
echo "6. Updating genesis address configuration..."
GENESIS_ADDR=$(cat /var/lib/aitbc/keystore/aitbc1genesis.json | jq -r '.address')
echo "Genesis address: $GENESIS_ADDR"
sed -i "s|proposer_id=.*|proposer_id=$GENESIS_ADDR|g" /etc/aitbc/.env
sed -i "s|trusted_proposers=.*|trusted_proposers=$GENESIS_ADDR|g" /etc/aitbc/.env
# Copy genesis and allocations to standard location
echo "7. Copying genesis and allocations to standard location..."
mkdir -p /var/lib/aitbc/data/ait-mainnet
cp /opt/aitbc/apps/blockchain-node/data/ait-mainnet/genesis.json /var/lib/aitbc/data/ait-mainnet/
cp /opt/aitbc/apps/blockchain-node/data/ait-mainnet/allocations.json /var/lib/aitbc/data/ait-mainnet/
cp /opt/aitbc/apps/blockchain-node/keystore/* /var/lib/aitbc/keystore/
# Note: systemd services should already use /etc/aitbc/.env
# No need to update systemd if they are properly configured
# Enable and start blockchain services
echo "8. Starting blockchain services..."
systemctl daemon-reload
systemctl enable aitbc-blockchain-node aitbc-blockchain-rpc
systemctl start aitbc-blockchain-node aitbc-blockchain-rpc
echo "✅ Genesis authority setup completed successfully!"
echo "aitbc1 is now configured as the genesis authority node."
echo "Genesis address: $GENESIS_ADDR"