Repository navigation
0.1.2
This release makes the macOS delayed auto-update script capable of updating ✅ any NetBird installation:
- 🖥️ GUI/pkg installation (standard
.pkg//Applications/NetBird.app) - 🍺 Homebrew installation
- 🧰 Other CLI-only installs
It also includes 🔁 self-update, 🧾 log retention, and 🔎 robust version detection — similar to the Windows delayed update helper.
✨ Highlights
-
🧩 Supports all common NetBird install types on macOS
- Detects whether NetBird is installed via:
- 🍺 Homebrew (
/opt/homebrew/Cellar/netbird/...or/usr/local/Cellar/netbird/...), or - 🖥️ standard pkg/app (
/Applications/NetBird.app/...symlinked from/usr/local/bin/netbird), or - 🧰 “other” / custom locations
- 🍺 Homebrew (
- Chooses the appropriate update mechanism for each type.
- Detects whether NetBird is installed via:
-
🍺 Homebrew-based update (non-root brew call)
- When
netbirdcomes from Homebrew:- 👤 detects the owner user of the
brewbinary ▶️ runs as that user:(orsudo -u <brew-owner> brew upgrade netbirdio/tap/netbird
brew upgrade netbirdif that formula is installed)- 🛡️ all executed from a root context while respecting Homebrew permissions.
- 👤 detects the owner user of the
- When
-
📦 macOS pkg-based update
- When
netbirdis part of/Applications/NetBird.app/ system pkg:- 🧭 determines the correct pkg URL for the current arch (
amd64orarm64):https://pkgs.netbird.io/macos/<arch> - ⬇️ downloads the latest
.pkginto/tmp/netbird.pkg - 🛠️ installs it with:
installer -pkg /tmp/netbird.pkg -target /
- 🔄 restarts the NetBird service afterwards.
- 🧭 determines the correct pkg URL for the current arch (
- When
-
🔁 Script self-update
- 🏷️ checks the latest GitHub release of
NetHorror/netbird-delayed-auto-update-macos - 🧮 compares the release tag (
X.Y.Z) withSCRIPT_VERSION(0.1.2) - If newer:
- 🧬 tries
git pull --ff-only(if the script is in a git checkout) - ⬇️ otherwise downloads
netbird-delayed-update-macos.shfrom the tagged version onraw.githubusercontent.comand overwrites the local script
- 🧬 tries
- ✅ the updated script is used on the next run.
- 🏷️ checks the latest GitHub release of
-
🧾 Log retention
- Logs are written to:
/var/lib/netbird-delayed-update/netbird-delayed-update-*.log - 🧹
--log-retention-days(default:60) controls how long logs are kept - 🚫
--log-retention-days 0disables cleanup.
- Logs are written to:
-
⏳ Version aging / delayed rollout
- Latest available version becomes a candidate
- 🕒 Candidate must age for
--delay-daysdays (default:10) before upgrades are allowed - 🧠 State is stored in:
/var/lib/netbird-delayed-update/state.json - 🧷 Age calculation is clamped to
>= 0days (no negative values if system time moves backwards)
🧠 How it works (short version)
On each run (manual or via launchd), the script:
- 🔎 Resolves
netbirdand reads the local version:netbird version
- 🌐 Fetches the latest available version from:
and parses the
https://pkgs.netbird.io/releases/latestvX.Y.Ztag. - 🧠 Updates
state.jsonwith the candidate version and first-seen timestamp. - ⏳ If the candidate is younger than
--delay-days→ logs that it is still “aging” and exits. - ✅ If the candidate is old enough and newer than the local version:
- 🧩 detects install type (
brewvspkg/app/other) - 🍺 Homebrew: runs
brew upgrade …as the brew owner user - 📦 pkg/app/other: downloads and installs the latest macOS
.pkgdirectly
- 🧩 detects install type (
- 🔄 Stops and restarts the NetBird service around the upgrade.
⚙️ Usage recap
🕒 Install launchd job with defaults:
sudo ./netbird-delayed-update-macos.sh --install🧰 Install with custom parameters:
sudo ./netbird-delayed-update-macos.sh --install \
--delay-days 10 \
--max-random-delay-seconds 3600 \
--log-retention-days 60 \
--daily-time "04:00" \
-r🧪 Manual one-off run (for testing):
sudo ./netbird-delayed-update-macos.sh \
--delay-days 0 \
--max-random-delay-seconds 0 \
--log-retention-days 60🗑️ Uninstall the launchd job:
sudo ./netbird-delayed-update-macos.sh --uninstall🧹 Uninstall and also remove state/logs:
sudo ./netbird-delayed-update-macos.sh --uninstall --remove-state