Skip to main content

Automated Edge Updater (updater.sh)

📌 What is this for? (Quick Summary for New Interns)​

In Simple Words:
When the Raspberry Pi is bolted inside a pod running on a test track in a remote facility, you cannot easily walk over with a keyboard and monitor every time you push a bug fix to GitHub.

This small script solves that:

  • Every 60 seconds, it checks GitHub (git fetch origin main).
  • If you pushed new code, it automatically pulls the latest changes, recompiles the Go server if needed, and restarts the background services.
  • You push to GitHub; the vehicle updates itself automatically.

1. How the Updater Works​

flowchart TD
Cron["Cron Timer (Runs every 60 seconds)"] --> CheckGit["Checks GitHub for new commits"]
CheckGit --> IsNew{"Any new code on main?"}
IsNew -->|No changes| Sleep["Exit (Do nothing)"]
IsNew -->|Yes, new code found| Pull["git pull origin main"]
Pull --> Rebuild["Rebuild Go server binary if needed"]
Rebuild --> Restart["Restart background systemd services"]
Restart --> Log["Write success note to ~/updater.log"]

2. How to Check If It Is Working​

If you want to verify what the updater recently did on the Pi:

# View the last few lines of the updater log:
tail -n 25 ~/updater.log

# Check if the cron job is active:
crontab -l

If everything is nominal, you will see entries like:

[2026-11-03 12:11:12] 🚀 Services built, updated, and restarted successfully!