Automatically keep Client St0r up to date with the latest releases from GitHub.
✅ Automatic Updates
- Checks GitHub for new releases daily at 2 AM
- Pulls latest code automatically
- Runs database migrations
- Restarts all services
- Zero manual intervention required
✅ Safe Updates
- Stashes local changes before updating
- Runs migrations automatically
- Verifies services restart successfully
- Detailed logging of all actions
- Rollback capability if needed
✅ Complete Automation
- No SSH required
- No manual migration running
- No manual service restarts
- Works for any user/installation directory
cd /path/to/clientst0r
./scripts/install_auto_update.shThis installs:
- Auto-update script at
scripts/auto_update.sh - Systemd service:
clientst0r-auto-update.service - Systemd timer:
clientst0r-auto-update.timer - Sudo permissions for service restarts
The auto-update system handles:
- ✅
git pull origin main- Pull latest code - ✅
pip install -r requirements.txt- Update dependencies - ✅
python manage.py migrate- Run database migrations - ✅
python manage.py collectstatic- Collect static files - ✅
systemctl restart clientst0r-*- Restart all services
Once installed, updates happen automatically:
- Daily at 2 AM - Checks for and applies updates
- On boot (+10 min) - Checks after system restarts
No action required on your part!
To update immediately:
# Using the script directly
/path/to/clientst0r/scripts/auto_update.sh
# Using systemd service
sudo systemctl start clientst0r-auto-update.service
# Using Django management command
cd /path/to/clientst0r
source venv/bin/activate
python manage.py auto_update# Django command
python manage.py auto_update --check-only
# Or check manually
git fetch origin main
git log HEAD..origin/main# Check timer status
sudo systemctl status clientst0r-auto-update.timer
# View next scheduled run
sudo systemctl list-timers clientst0r-auto-update.timer
# Check last service run
sudo systemctl status clientst0r-auto-update.service# Watch logs in real-time
tail -f /var/log/clientst0r/auto-update.log
# View recent logs
tail -n 50 /var/log/clientst0r/auto-update.log
# View all logs
cat /var/log/clientst0r/auto-update.log# Disable automatic updates
sudo systemctl disable clientst0r-auto-update.timer
sudo systemctl stop clientst0r-auto-update.timer
# Enable automatic updates
sudo systemctl enable clientst0r-auto-update.timer
sudo systemctl start clientst0r-auto-update.timer
# Trigger update now
sudo systemctl start clientst0r-auto-update.service-
Check for Updates
- Fetches latest code from GitHub
- Compares local vs remote versions
- Exits if already up to date
-
Stash Local Changes
- Saves any uncommitted local changes
- Prevents conflicts during pull
- Can be restored if needed
-
Pull Latest Code
- Downloads new code from GitHub
- Updates all files
- Reports new version
-
Update Dependencies
- Installs/updates Python packages
- Uses existing virtual environment
- Non-blocking (continues on failure)
-
Run Migrations
- Applies database schema changes
- Required for some updates (like v2.49.5)
- Automatically applied
-
Collect Static Files
- Updates CSS, JavaScript, images
- Ensures UI is current
- Non-blocking
-
Restart Services
- Restarts Gunicorn (web server)
- Restarts Scheduler (background tasks)
- Restarts PSA/RMM sync services
- Restarts Monitor service
- Verifies all services are running
Default schedule:
- Daily: 2:00 AM (OnCalendar=02:00)
- On Boot: 10 minutes after system starts
- Persistent: If missed, runs as soon as possible
All update activity logged to:
- Main log:
/var/log/clientst0r/auto-update.log - Service output:
journalctl -u clientst0r-auto-update.service
Log includes:
- Timestamps
- Each step executed
- Success/failure indicators
- Error messages
- Version changes
Edit the timer:
sudo systemctl edit clientst0r-auto-update.timerAdd custom schedule:
[Timer]
# Run every 6 hours
OnCalendar=00/6:00Common schedules:
OnCalendar=hourly- Every hourOnCalendar=daily- Daily at midnightOnCalendar=weekly- Weekly on MondayOnCalendar=Mon,Wed,Fri 02:00- Specific daysOnCalendar=*-*-* 02:00:00- Daily at 2 AM
Then reload:
sudo systemctl daemon-reload
sudo systemctl restart clientst0r-auto-update.timerEdit scripts/auto_update.sh to customize:
- Pre-update hooks
- Post-update actions
- Notification methods
- Additional services to restart
Check timer is enabled:
sudo systemctl is-enabled clientst0r-auto-update.timerCheck next run time:
sudo systemctl list-timers --all | grep clientst0rView error logs:
sudo journalctl -u clientst0r-auto-update.service -n 50Or:
tail -n 50 /var/log/clientst0r/auto-update.logCommon issues:
- Git conflicts: Local changes conflict with remote
- Migration errors: Database schema incompatibility
- Service restart failed: Permission issues
If auto-update fails:
# View what failed
sudo systemctl status clientst0r-auto-update.service
# Run update manually to see errors
cd /path/to/clientst0r
./scripts/auto_update.sh
# Or update completely manually
git pull origin main
source venv/bin/activate
python manage.py migrate
sudo systemctl restart clientst0r-gunicornIf your local changes were stashed:
cd /path/to/clientst0r
git stash list
git stash pop # Restore most recent stashThe auto-update system requires sudo permissions to restart services. These are granted via /etc/sudoers.d/clientst0r-auto-update:
# Allow user to restart Client St0r services without password
username ALL=(ALL) NOPASSWD: /bin/systemctl restart clientst0r-*.service
This is minimal privilege - only allows:
- Restarting Client St0r services (not other services)
- Checking service status
- No other sudo commands
To remove auto-update system:
# Disable and stop timer
sudo systemctl disable clientst0r-auto-update.timer
sudo systemctl stop clientst0r-auto-update.timer
# Remove systemd files
sudo rm /etc/systemd/system/clientst0r-auto-update.service
sudo rm /etc/systemd/system/clientst0r-auto-update.timer
sudo rm /etc/sudoers.d/clientst0r-auto-update
# Reload systemd
sudo systemctl daemon-reload
# Optionally remove script
rm /path/to/clientst0r/scripts/auto_update.shQ: Will this update break my installation? A: No. The script pulls official releases which are tested. Migrations are run automatically. Services are verified after restart.
Q: What if I have local customizations? A: Local changes are automatically stashed before update and can be restored after.
Q: Can I disable auto-updates?
A: Yes. Run: sudo systemctl disable clientst0r-auto-update.timer
Q: Will this restart my services in the middle of the day? A: No. Default schedule is 2 AM when traffic is lowest. You can customize the schedule.
Q: What if an update fails? A: The script exits immediately on failure. Your installation remains on the working version. Check logs and update manually if needed.
Q: Do I still get update notifications in the UI? A: Yes! The System Updates page still shows available updates, but now they're applied automatically.
If auto-updates aren't working:
- Check timer status:
sudo systemctl status clientst0r-auto-update.timer - View logs:
tail -f /var/log/clientst0r/auto-update.log - Test manually:
./scripts/auto_update.sh - Open GitHub issue with logs
Enjoy automatic updates! 🚀