SYSTEMD SYNC FIX: Resolve wrong repository path in systemd linking
Issues Fixed:
❌ Repository path pointing to api-tests-workspace instead of systemd-sync-workspace
❌ Systemd files being synced from wrong location
❌ Missing debugging information for path resolution
❌ Script path confusion between different workspaces
Root Cause:
- Systemd sync workflow using wrong repository path
- Linking script getting incorrect directory path
- Sed commands not covering all path variations
- Missing debugging to identify path issues
Solution Applied:
✅ Enhanced path correction with comprehensive sed commands
✅ Added debugging information for directory verification
✅ Fixed all potential path variations
✅ Better error reporting and directory validation
Path Corrections:
- Fixed /opt/aitbc/api-tests-workspace/repo/systemd → /opt/aitbc/systemd-sync-workspace/repo/systemd
- Added comprehensive sed command to catch all path variations
- Added debugging to show current directory and systemd directory existence
- Enhanced error reporting for troubleshooting
Debugging Improvements:
- Current directory display
- Systemd directory existence verification
- Script update confirmation
- Step-by-step progress reporting
Impact:
- Systemd files now sync from correct repository location
- Better debugging information for troubleshooting
- Comprehensive path correction prevents future issues
- Reliable systemd synchronization
This resolves the repository path issue that was causing
systemd files to sync from the wrong workspace location.
SYSTEMD PATH FIX: Correct repository path for systemd sync in CI environments
Issue Fixed:
❌ Repository systemd directory not found: /opt/aitbc/systemd
❌ CI workflows looking for wrong repository path
❌ Systemd sync failing in CI environments
Root Cause:
- CI workflows clone repository to workspace directories
- Systemd sync script hardcoded to /opt/aitbc/systemd
- Repository actually in /opt/aitbc/*-workspace/repo/systemd
- Path mismatch causing sync failures
Solution Applied:
✅ Dynamic path updates in all workflows
✅ sed commands to update REPO_SYSTEMD_DIR at runtime
✅ Correct paths for each workflow workspace
✅ Fallback manual sync with correct paths
Fixed Workflows:
1. systemd-sync.yml:
- Updated to use /opt/aitbc/systemd-sync-workspace/repo/systemd
- Dynamic path update before running script
2. integration-tests.yml:
- Updated to use /opt/aitbc/integration-tests-workspace/repo/systemd
- Dynamic path update before running script
3. api-endpoint-tests.yml:
- Updated to use /opt/aitbc/api-tests-workspace/repo/systemd
- Dynamic path update before running script
Changes Made:
- Added sed commands to update REPO_SYSTEMD_DIR
- Each workflow uses its own workspace path
- Maintains original script functionality
- Preserves fallback manual sync
Impact:
- Systemd sync now works in CI environments
- Service-dependent workflows can start services
- Integration and API tests can run properly
- No more path-related failures
This resolves the critical path issue that was preventing
systemd sync and service-dependent workflows from working
in the CI/CD environment.
SYSTEMD SYNC: Link active systemd files to repository for automatic sync
Problem Solved:
❌ Gap between repository systemd files and active systemd files
❌ Development changes in repo not reflected in running services
❌ Manual sync required to update systemd configuration
❌ Risk of configuration drift between repo and production
Solution Implemented:
✅ Symbolic links from /etc/systemd/system/ to /opt/aitbc/systemd
✅ Automatic sync script for manual operations
✅ CI/CD workflow for automatic sync on repository changes
✅ Backup mechanism for safe operations
✅ Verification and status checking
Files Created:
1. scripts/link-systemd.sh:
- Creates symbolic links for all aitbc-* services
- Handles .d directories automatically
- Creates backups before making changes
- Provides comprehensive status reporting
2. scripts/sync-systemd.sh:
- Alternative copy-based sync method
- For environments where symbolic links aren't preferred
- Maintains file independence while keeping sync
3. .gitea/workflows/systemd-sync.yml:
- Automatic CI/CD sync on repository changes
- Triggers when systemd files are modified
- Verifies link creation and service status
- Provides manual instructions
Benefits:
✅ Active systemd files always match repository
✅ No configuration drift between repo and production
✅ Changes in repo immediately reflected
✅ Automatic sync on every repository update
✅ Safe operations with backups
✅ CI/CD integration for automation
Usage:
- Manual: sudo ./scripts/link-systemd.sh
- CI/CD: Automatic on systemd file changes
- Verification: ls -la /etc/systemd/system/aitbc-*
- Status: sudo systemctl status aitbc-*
This eliminates the gap between repository and active systemd
configuration, ensuring the repository always contains the current
running state and changes are immediately reflected.