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.