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.