refactor: move central .env to /etc/aitbc/blockchain.env
Some checks failed
Documentation Validation / validate-docs (push) Has been cancelled
Some checks failed
Documentation Validation / validate-docs (push) Has been cancelled
- Move central configuration from /opt/aitbc/.env to /etc/aitbc/blockchain.env - Follow system standards for configuration file placement - Update all workflow steps to use new config location - Update systemd services to use /etc/aitbc/blockchain.env - Update environment management section with new paths - Maintain backup strategy with .backup files - Standardize configuration location across all AITBC services This aligns with Linux filesystem hierarchy standards where /etc/ is the proper location for system configuration files.
This commit is contained in:
@@ -17,22 +17,22 @@ This workflow sets up a two-node AITBC blockchain network (aitbc1 as genesis aut
|
||||
|
||||
- `/opt/aitbc/venv` - Central Python virtual environment
|
||||
- `/opt/aitbc/requirements.txt` - Python dependencies
|
||||
- `/opt/aitbc/.env` - Central environment configuration
|
||||
- `/etc/aitbc/blockchain.env` - Central environment configuration
|
||||
- `/var/lib/aitbc/data` - Blockchain database files
|
||||
- `/var/lib/aitbc/keystore` - Wallet credentials
|
||||
- `/etc/aitbc/` - System configuration files
|
||||
- `/var/log/aitbc/` - Service logs
|
||||
|
||||
## Steps
|
||||
|
||||
### Environment Configuration
|
||||
|
||||
The workflow uses the central `/opt/aitbc/.env` file as the base configuration for both nodes:
|
||||
The workflow uses the central `/etc/aitbc/blockchain.env` file as the configuration for both nodes:
|
||||
|
||||
- **Base Configuration**: The central `.env` contains all default settings
|
||||
- **Node-Specific Adaptation**: Each node adapts the `.env` for its role (genesis vs follower)
|
||||
- **Base Configuration**: The central config contains all default settings
|
||||
- **Node-Specific Adaptation**: Each node adapts the config for its role (genesis vs follower)
|
||||
- **Path Updates**: Paths are updated to use the standardized directory structure
|
||||
- **Backup Strategy**: Original `.env` is backed up before modifications
|
||||
- **Backup Strategy**: Original config is backed up before modifications
|
||||
- **Standard Location**: Config moved to `/etc/aitbc/` following system standards
|
||||
|
||||
### 1. Prepare aitbc1 (Genesis Authority Node)
|
||||
|
||||
@@ -54,19 +54,22 @@ mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc
|
||||
ls -la /var/lib/aitbc/ || echo "Creating /var/lib/aitbc/ structure..."
|
||||
|
||||
# Copy and adapt central .env for aitbc1 (genesis authority)
|
||||
cp /opt/aitbc/.env /opt/aitbc/.env.aitbc1.backup
|
||||
cp /opt/aitbc/.env /etc/aitbc/blockchain.env.backup
|
||||
|
||||
# Move central .env to standard config location
|
||||
mv /opt/aitbc/.env /etc/aitbc/blockchain.env
|
||||
|
||||
# Update .env for aitbc1 genesis authority configuration
|
||||
sed -i 's|proposer_id=.*|proposer_id=aitbc1genesis|g' /opt/aitbc/.env
|
||||
sed -i 's|keystore_path=/opt/aitbc/apps/blockchain-node/keystore|keystore_path=/var/lib/aitbc/keystore|g' /opt/aitbc/.env
|
||||
sed -i 's|keystore_password_file=/opt/aitbc/apps/blockchain-node/keystore/.password|keystore_password_file=/var/lib/aitbc/keystore/.password|g' /opt/aitbc/.env
|
||||
sed -i 's|db_path=./data/ait-mainnet/chain.db|db_path=/var/lib/aitbc/data/ait-mainnet/chain.db|g' /opt/aitbc/.env
|
||||
sed -i 's|enable_block_production=true|enable_block_production=true|g' /opt/aitbc/.env
|
||||
sed -i 's|gossip_broadcast_url=redis://127.0.0.1:6379|gossip_broadcast_url=redis://localhost:6379|g' /opt/aitbc/.env
|
||||
sed -i 's|p2p_bind_port=8005|p2p_bind_port=7070|g' /opt/aitbc/.env
|
||||
sed -i 's|proposer_id=.*|proposer_id=aitbc1genesis|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|keystore_path=/opt/aitbc/apps/blockchain-node/keystore|keystore_path=/var/lib/aitbc/keystore|g' /etc/aitbc/blockchain.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/blockchain.env
|
||||
sed -i 's|db_path=./data/ait-mainnet/chain.db|db_path=/var/lib/aitbc/data/ait-mainnet/chain.db|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|enable_block_production=true|enable_block_production=true|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|gossip_broadcast_url=redis://127.0.0.1:6379|gossip_broadcast_url=redis://localhost:6379|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|p2p_bind_port=8005|p2p_bind_port=7070|g' /etc/aitbc/blockchain.env
|
||||
|
||||
# Add trusted proposers for follower nodes
|
||||
echo "trusted_proposers=aitbc1genesis" >> /opt/aitbc/.env
|
||||
echo "trusted_proposers=aitbc1genesis" >> /etc/aitbc/blockchain.env
|
||||
|
||||
# Create genesis block with wallets
|
||||
cd /opt/aitbc/apps/blockchain-node
|
||||
@@ -81,11 +84,9 @@ cp data/ait-mainnet/genesis.json /var/lib/aitbc/data/ait-mainnet/
|
||||
cp data/ait-mainnet/allocations.json /var/lib/aitbc/data/ait-mainnet/
|
||||
cp keystore/* /var/lib/aitbc/keystore/
|
||||
|
||||
# Update systemd services to use central .env and standard paths
|
||||
# Note: systemd services already reference /opt/aitbc/.env by default
|
||||
# The separate .env.production file has been merged into central .env
|
||||
# No need to modify EnvironmentFile as they should use the central .env
|
||||
# Just ensure the paths in .env are correct for the standard directory structure
|
||||
# Update systemd services to use standard config location
|
||||
# Update EnvironmentFile paths to use /etc/aitbc/blockchain.env
|
||||
sed -i 's|EnvironmentFile=/opt/aitbc/.env|EnvironmentFile=/etc/aitbc/blockchain.env|g' /opt/aitbc/systemd/aitbc-blockchain-*.service
|
||||
|
||||
# Enable and start blockchain services
|
||||
systemctl daemon-reload
|
||||
@@ -129,24 +130,27 @@ mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc
|
||||
ls -la /var/lib/aitbc/ || echo "Creating /var/lib/aitbc/ structure..."
|
||||
|
||||
# Copy and adapt central .env for aitbc (follower node)
|
||||
cp /opt/aitbc/.env /opt/aitbc/.env.aitbc.backup
|
||||
cp /opt/aitbc/.env /etc/aitbc/blockchain.env.backup
|
||||
|
||||
# Move central .env to standard config location
|
||||
mv /opt/aitbc/.env /etc/aitbc/blockchain.env
|
||||
|
||||
# Update .env for aitbc follower node configuration
|
||||
sed -i 's|proposer_id=.*|proposer_id=follower-node-aitbc|g' /opt/aitbc/.env
|
||||
sed -i 's|keystore_path=/opt/aitbc/apps/blockchain-node/keystore|keystore_path=/var/lib/aitbc/keystore|g' /opt/aitbc/.env
|
||||
sed -i 's|keystore_password_file=/opt/aitbc/apps/blockchain-node/keystore/.password|keystore_password_file=/var/lib/aitbc/keystore/.password|g' /opt/aitbc/.env
|
||||
sed -i 's|db_path=./data/ait-mainnet/chain.db|db_path=/var/lib/aitbc/data/ait-mainnet/chain.db|g' /opt/aitbc/.env
|
||||
sed -i 's|enable_block_production=true|enable_block_production=false|g' /opt/aitbc/.env
|
||||
sed -i 's|gossip_broadcast_url=redis://127.0.0.1:6379|gossip_broadcast_url=redis://10.1.223.40:6379|g' /opt/aitbc/.env
|
||||
sed -i 's|p2p_bind_port=8005|p2p_bind_port=7070|g' /opt/aitbc/.env
|
||||
sed -i 's|trusted_proposers=.*|trusted_proposers=ait1apmaugx6csz50q07m99z8k44llry0zpl0yurl23hygarcey8z85qy4zr96|g' /opt/aitbc/.env
|
||||
sed -i 's|proposer_id=.*|proposer_id=follower-node-aitbc|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|keystore_path=/opt/aitbc/apps/blockchain-node/keystore|keystore_path=/var/lib/aitbc/keystore|g' /etc/aitbc/blockchain.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/blockchain.env
|
||||
sed -i 's|db_path=./data/ait-mainnet/chain.db|db_path=/var/lib/aitbc/data/ait-mainnet/chain.db|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|enable_block_production=true|enable_block_production=false|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|gossip_broadcast_url=redis://127.0.0.1:6379|gossip_broadcast_url=redis://10.1.223.40:6379|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|p2p_bind_port=8005|p2p_bind_port=7070|g' /etc/aitbc/blockchain.env
|
||||
sed -i 's|trusted_proposers=.*|trusted_proposers=ait1apmaugx6csz50q07m99z8k44llry0zpl0yurl23hygarcey8z85qy4zr96|g' /etc/aitbc/blockchain.env
|
||||
|
||||
# Note: aitbc should sync genesis from aitbc1, not copy it
|
||||
# The follower node will receive the genesis block via blockchain sync
|
||||
|
||||
# Note: systemd services already reference /opt/aitbc/.env by default
|
||||
# No need to modify EnvironmentFile as they should use the central .env
|
||||
# The .env file has been updated above with follower node configuration
|
||||
# Update systemd services to use standard config location
|
||||
# Update EnvironmentFile paths to use /etc/aitbc/blockchain.env
|
||||
sed -i 's|EnvironmentFile=/opt/aitbc/.env|EnvironmentFile=/etc/aitbc/blockchain.env|g' /opt/aitbc/systemd/aitbc-blockchain-*.service
|
||||
|
||||
# Stop any existing services and clear old data
|
||||
systemctl stop aitbc-blockchain-* 2>/dev/null || true
|
||||
@@ -260,15 +264,15 @@ ssh aitbc "curl -s \"http://localhost:8006/rpc/getBalance/$WALLET_ADDR\" | jq ."
|
||||
|
||||
### Central .env Configuration
|
||||
|
||||
The workflow uses `/opt/aitbc/.env` as the central configuration file:
|
||||
The workflow uses `/etc/aitbc/blockchain.env` as the central configuration file:
|
||||
|
||||
```bash
|
||||
# View current configuration
|
||||
cat /opt/aitbc/.env
|
||||
cat /etc/aitbc/blockchain.env
|
||||
|
||||
# Restore from backup if needed
|
||||
cp /opt/aitbc/.env.aitbc1.backup /opt/aitbc/.env # aitbc1
|
||||
cp /opt/aitbc/.env.aitbc.backup /opt/aitbc/.env # aitbc
|
||||
cp /etc/aitbc/blockchain.env.backup /etc/aitbc/blockchain.env # aitbc1
|
||||
cp /etc/aitbc/blockchain.env.backup /etc/aitbc/blockchain.env # aitbc
|
||||
|
||||
# Key configuration differences:
|
||||
# aitbc1: proposer_id=aitbc1genesis, enable_block_production=true
|
||||
@@ -277,13 +281,13 @@ cp /opt/aitbc/.env.aitbc.backup /opt/aitbc/.env # aitbc
|
||||
|
||||
### Service Configuration
|
||||
|
||||
- **Environment File**: All services use `/opt/aitbc/.env` (merged from .env.production)
|
||||
- **Environment File**: All services use `/etc/aitbc/blockchain.env` (standard config location)
|
||||
- **Virtual Environment**: Central venv at `/opt/aitbc/venv`
|
||||
- **Database Files**: `/var/lib/aitbc/data`
|
||||
- **Wallet Credentials**: `/var/lib/aitbc/keystore`
|
||||
- **Service Logs**: `/var/log/aitbc/` via journald
|
||||
- **Standardized Paths**: All paths use `/var/lib/aitbc/` structure
|
||||
- **No Separate Config Files**: `.env.production` merged into central `.env`
|
||||
- **Config Location**: Central config moved to `/etc/aitbc/` following standards
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -291,4 +295,4 @@ cp /opt/aitbc/.env.aitbc.backup /opt/aitbc/.env # aitbc
|
||||
- **Sync issues**: Verify Redis connectivity between nodes
|
||||
- **Transaction failures**: Check wallet nonce and balance
|
||||
- **Permission errors**: Ensure `/var/lib/aitbc/` is owned by root with proper permissions
|
||||
- **Configuration issues**: Verify `.env` file contents and systemd service EnvironmentFile paths
|
||||
- **Configuration issues**: Verify `/etc/aitbc/blockchain.env` file contents and systemd service EnvironmentFile paths
|
||||
|
||||
Reference in New Issue
Block a user