From fd75eb32bccdccaca26005b40568cc7fbfc60a51 Mon Sep 17 00:00:00 2001 From: aitbc Date: Tue, 26 May 2026 15:54:17 +0200 Subject: [PATCH] Fix workflow scripts: create blockchain.env directly instead of copying from non-existent /opt/aitbc/.env - 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 --- .../01_preflight_setup_hermes.sh | 26 ++++++++++++++++-- .../01_preflight_setup_hermes_simple.sh | 26 ++++++++++++++++-- scripts/workflow/01_preflight_setup.sh | 27 ++++++++++++++++--- 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/scripts/workflow-hermes/01_preflight_setup_hermes.sh b/scripts/workflow-hermes/01_preflight_setup_hermes.sh index bf0ef365..aa78eb57 100755 --- a/scripts/workflow-hermes/01_preflight_setup_hermes.sh +++ b/scripts/workflow-hermes/01_preflight_setup_hermes.sh @@ -80,8 +80,30 @@ hermes execute --agent GenesisAgent --task update_systemd_config || { echo "5. Setting up central configuration via hermes agents..." hermes execute --agent CoordinatorAgent --task setup_central_config || { echo "⚠️ hermes config setup failed - using manual method" - cp /opt/aitbc/.env /etc/aitbc/blockchain.env.backup 2>/dev/null || true - mv /opt/aitbc/.env /etc/aitbc/blockchain.env 2>/dev/null || true + # 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 } # 6. Setup AITBC CLI tool (via hermes) diff --git a/scripts/workflow-hermes/01_preflight_setup_hermes_simple.sh b/scripts/workflow-hermes/01_preflight_setup_hermes_simple.sh index ed58b057..76832b17 100755 --- a/scripts/workflow-hermes/01_preflight_setup_hermes_simple.sh +++ b/scripts/workflow-hermes/01_preflight_setup_hermes_simple.sh @@ -48,8 +48,30 @@ systemctl daemon-reload # 5. Setup central configuration file echo "5. Setting up central configuration file..." -cp /opt/aitbc/.env /etc/aitbc/blockchain.env.backup 2>/dev/null || true -mv /opt/aitbc/.env /etc/aitbc/blockchain.env 2>/dev/null || true +# 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 # 6. Setup AITBC CLI tool echo "6. Setting up AITBC CLI tool..." diff --git a/scripts/workflow/01_preflight_setup.sh b/scripts/workflow/01_preflight_setup.sh index 5cc3c096..eb2dc165 100755 --- a/scripts/workflow/01_preflight_setup.sh +++ b/scripts/workflow/01_preflight_setup.sh @@ -22,9 +22,30 @@ systemctl daemon-reload # 3. Create central configuration file echo "3. Setting up central configuration file..." -cp /opt/aitbc/.env /etc/aitbc/blockchain.env.backup 2>/dev/null || true -# Ensure blockchain.env is in the correct location -mv /opt/aitbc/.env /etc/aitbc/blockchain.env 2>/dev/null || true +# 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..."