- Update 01_preflight_setup.sh to create blockchain.env with defaults - Update hermes preflight setup scripts to create blockchain.env with defaults - Remove dependency on /opt/aitbc/.env which doesn't exist
76 lines
2.8 KiB
Bash
Executable File
76 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Pre-Flight Setup Script for AITBC Multi-Node Blockchain
|
|
# This script prepares the system for multi-node blockchain deployment
|
|
|
|
set -e # Exit on any error
|
|
|
|
echo "=== AITBC Multi-Node Blockchain Pre-Flight Setup ==="
|
|
|
|
# 1. Stop existing services
|
|
echo "1. Stopping existing services..."
|
|
systemctl stop aitbc-blockchain-* 2>/dev/null || true
|
|
|
|
# 2. Update ALL systemd configurations (main files + drop-ins + overrides)
|
|
echo "2. Updating systemd configurations..."
|
|
# Update main service files
|
|
sed -i 's|EnvironmentFile=/opt/aitbc/.env|EnvironmentFile=/etc/aitbc/blockchain.env|g' /opt/aitbc/systemd/aitbc-blockchain-*.service
|
|
# Update drop-in configs
|
|
find /etc/systemd/system/aitbc-blockchain-*.service.d/ -name "10-central-env.conf" -exec sed -i 's|EnvironmentFile=/opt/aitbc/.env|EnvironmentFile=/etc/aitbc/blockchain.env|g' {} \; 2>/dev/null || true
|
|
# Fix override configs (wrong venv paths)
|
|
find /etc/systemd/system/aitbc-blockchain-*.service.d/ -name "override.conf" -exec sed -i 's|/opt/aitbc/apps/blockchain-node/.venv/bin/python3|/opt/aitbc/venv/bin/python3|g' {} \; 2>/dev/null || true
|
|
systemctl daemon-reload
|
|
|
|
# 3. Create central configuration file
|
|
echo "3. Setting up central configuration file..."
|
|
# Create blockchain.env if it doesn't exist
|
|
if [ ! -f "/etc/aitbc/blockchain.env" ]; then
|
|
echo "Creating /etc/aitbc/blockchain.env with default configuration..."
|
|
cat > /etc/aitbc/blockchain.env << 'EOF'
|
|
# AITBC Blockchain Configuration
|
|
# This file contains shared environment variables for all AITBC services
|
|
NODE_ENV=production
|
|
DEBUG=false
|
|
LOG_LEVEL=INFO
|
|
CHAIN_ID=ait-mainnet
|
|
BLOCK_TIME=5
|
|
NETWORK_ID=1337
|
|
CONSENSUS=proof_of_authority
|
|
rpc_bind_host=0.0.0.0
|
|
rpc_bind_port=8006
|
|
auto_sync_enabled=true
|
|
island_id=ait-mainnet-island
|
|
supported_chains=ait-mainnet,ait-testnet
|
|
default_peer_rpc_url=http://aitbc1:8006
|
|
EOF
|
|
echo "Created /etc/aitbc/blockchain.env"
|
|
else
|
|
echo "/etc/aitbc/blockchain.env already exists"
|
|
fi
|
|
|
|
# 4. Setup AITBC CLI tool
|
|
echo "4. Setting up AITBC CLI tool..."
|
|
# Use central virtual environment (dependencies already installed)
|
|
source /opt/aitbc/venv/bin/activate
|
|
pip install -e /opt/aitbc/cli/ 2>/dev/null || true
|
|
echo 'alias aitbc="source /opt/aitbc/venv/bin/activate && aitbc"' >> ~/.bashrc
|
|
source ~/.bashrc
|
|
|
|
# 5. Clean old data (optional but recommended)
|
|
echo "5. Cleaning old data..."
|
|
rm -rf /var/lib/aitbc/data/ait-mainnet/*
|
|
rm -rf /var/lib/aitbc/keystore/*
|
|
|
|
# 6. Create keystore password file
|
|
echo "6. Creating keystore password file..."
|
|
mkdir -p /var/lib/aitbc/keystore
|
|
echo 'aitbc123' > /var/lib/aitbc/keystore/.password
|
|
chmod 600 /var/lib/aitbc/keystore/.password
|
|
|
|
# 7. Verify setup
|
|
echo "7. Verifying setup..."
|
|
aitbc --help 2>/dev/null || echo "CLI available but limited commands"
|
|
ls -la /etc/aitbc/blockchain.env
|
|
|
|
echo "✅ Pre-flight setup completed successfully!"
|
|
echo "System is ready for multi-node blockchain deployment."
|