Scripts Directory Reorganization - Complete: ✅ FUNCTIONAL ORGANIZATION: Scripts sorted into 8 logical categories - github/: GitHub and Git operations (6 files) - sync/: Synchronization and data replication (4 files) - security/: Security and audit operations (2 files) - monitoring/: System and service monitoring (6 files) - maintenance/: System maintenance and cleanup (4 files) - deployment/: Deployment and provisioning (11 files) - testing/: Testing and quality assurance (13 files) - utils/: Utility scripts and helpers (47 files) ✅ ROOT DIRECTORY CLEANED: Only README.md remains in scripts root - scripts/README.md: Main documentation - scripts/SCRIPTS_ORGANIZATION.md: Complete organization guide - All functional scripts moved to appropriate subdirectories ✅ SCRIPTS CATEGORIZATION: 📁 GitHub Operations: PR resolution, repository management, Git workflows 📁 Synchronization: Bulk sync, fast sync, sync detection, SystemD sync 📁 Security: Security audits, monitoring, vulnerability scanning 📁 Monitoring: Health checks, log monitoring, network monitoring, production monitoring 📁 Maintenance: Cleanup operations, performance tuning, weekly maintenance 📁 Deployment: Release building, node provisioning, DAO deployment, production deployment 📁 Testing: E2E testing, workflow testing, QA cycles, service testing 📁 Utilities: System management, setup scripts, helpers, tools ✅ ORGANIZATION BENEFITS: - Better Navigation: Scripts grouped by functionality - Easier Maintenance: Related scripts grouped together - Scalable Structure: Easy to add new scripts to appropriate categories - Clear Documentation: Comprehensive organization guide with descriptions - Improved Workflow: Quick access to relevant scripts by category ✅ DOCUMENTATION ENHANCED: - SCRIPTS_ORGANIZATION.md: Complete directory structure and usage guide - Quick Reference: Common script usage examples - Script Descriptions: Purpose and functionality for each script - Maintenance Guidelines: How to keep organization current DIRECTORY STRUCTURE: 📁 scripts/ ├── README.md (Main documentation) ├── SCRIPTS_ORGANIZATION.md (Organization guide) ├── github/ (6 files - GitHub operations) ├── sync/ (4 files - Synchronization) ├── security/ (2 files - Security) ├── monitoring/ (6 files - Monitoring) ├── maintenance/ (4 files - Maintenance) ├── deployment/ (11 files - Deployment) ├── testing/ (13 files - Testing) ├── utils/ (47 files - Utilities) ├── ci/ (existing - CI/CD) ├── deployment/ (existing - legacy deployment) ├── development/ (existing - Development tools) ├── monitoring/ (existing - Legacy monitoring) ├── services/ (existing - Service management) ├── testing/ (existing - Legacy testing) ├── utils/ (existing - Legacy utilities) ├── workflow/ (existing - Workflow automation) └── workflow-openclaw/ (existing - OpenClaw workflows) RESULT: Successfully reorganized 27 unorganized scripts into 8 functional categories, creating a clean, maintainable, and well-documented scripts directory structure with comprehensive organization guide.
88 lines
2.5 KiB
Bash
Executable File
88 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# AITBC Systemd Sync Script
|
|
# Syncs repository systemd files to active systemd configuration
|
|
# Eliminates gap between repo and running services
|
|
|
|
set -e
|
|
|
|
REPO_SYSTEMD_DIR="/opt/aitbc/systemd"
|
|
ACTIVE_SYSTEMD_DIR="/etc/systemd/system"
|
|
|
|
echo "=== AITBC SYSTEMD SYNC ==="
|
|
echo "Repository: $REPO_SYSTEMD_DIR"
|
|
echo "Active: $ACTIVE_SYSTEMD_DIR"
|
|
echo
|
|
|
|
# Check if running as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "❌ This script must be run as root (use sudo)"
|
|
echo " sudo $0"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if repository systemd directory exists
|
|
if [[ ! -d "$REPO_SYSTEMD_DIR" ]]; then
|
|
echo "❌ Repository systemd directory not found: $REPO_SYSTEMD_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
echo "🔍 Scanning for AITBC systemd files..."
|
|
|
|
# Create backup of current active systemd files
|
|
BACKUP_DIR="/opt/aitbc/systemd-backup-$(date +%Y%m%d-%H%M%S)"
|
|
echo "📦 Creating backup: $BACKUP_DIR"
|
|
mkdir -p "$BACKUP_DIR"
|
|
find "$ACTIVE_SYSTEMD_DIR" -name "aitbc-*" -type f -exec cp {} "$BACKUP_DIR/" \;
|
|
|
|
# Sync repository files to active systemd
|
|
echo "🔄 Syncing systemd files..."
|
|
|
|
# Copy all aitbc-* files from repo to active systemd
|
|
for file in "$REPO_SYSTEMD_DIR"/aitbc-*; do
|
|
if [[ -f "$file" ]]; then
|
|
filename=$(basename "$file")
|
|
target="$ACTIVE_SYSTEMD_DIR/$filename"
|
|
|
|
echo " 📄 Syncing: $filename"
|
|
|
|
# Copy file with proper permissions
|
|
cp "$file" "$target"
|
|
chmod 644 "$target"
|
|
|
|
# Handle .d directories
|
|
if [[ -d "${file}.d" ]]; then
|
|
target_dir="${target}.d"
|
|
echo " 📁 Syncing directory: ${filename}.d"
|
|
mkdir -p "$target_dir"
|
|
cp -r "${file}.d"/* "$target_dir/"
|
|
chmod 644 "$target_dir"/*
|
|
fi
|
|
fi
|
|
done
|
|
|
|
echo
|
|
echo "🔄 Reloading systemd daemon..."
|
|
systemctl daemon-reload
|
|
|
|
echo
|
|
echo "✅ Systemd sync completed!"
|
|
echo
|
|
echo "📊 Sync Summary:"
|
|
echo " Repository files: $(find "$REPO_SYSTEMD_DIR" -name 'aitbc-*' -type f | wc -l)"
|
|
echo " Active files: $(find "$ACTIVE_SYSTEMD_DIR" -name 'aitbc-*' -type f | wc -l)"
|
|
echo " Backup location: $BACKUP_DIR"
|
|
echo
|
|
echo "🔧 To restart services:"
|
|
echo " sudo systemctl restart aitbc-blockchain-node"
|
|
echo " sudo systemctl restart aitbc-coordinator-api"
|
|
echo " # ... or restart all AITBC services:"
|
|
echo " sudo systemctl restart aitbc-*"
|
|
echo
|
|
echo "🔍 To check status:"
|
|
echo " sudo systemctl status aitbc-*"
|
|
echo
|
|
echo "⚠️ If you need to restore backup:"
|
|
echo " sudo cp $BACKUP_DIR/* /etc/systemd/system/"
|
|
echo " sudo systemctl daemon-reload"
|