-
Notifications
You must be signed in to change notification settings - Fork 796
Add macOS agent update reliability improvements #7486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
f204bab to
710c2fd
Compare
|
Thanks for all the work you've done on this! It's a huge change, I haven't had time to try and delve into this yet but it's on my TODO list! |
d4e2077 to
41c02a2
Compare
Implements app bundle ZIP delivery for macOS agents, preserving code signatures by using external .msh configuration files instead of embedding settings into binaries. Features: - Dynamic app bundle packaging with separate .msh files - Installation type options: app ZIP, binary ZIP, deprecated mpkg - macOS uninstall command with bare binary download - Self-update support with hash verification - MeshAgentAPP container structure for app bundles - Agent update reliability improvements Changes: - webserver.js: Add createMacOSAppBundleZipPackage() for dynamic packaging - webserver.js: Detect self-updates vs initial installs for correct file delivery - meshcentral.js: Hash app bundle ZIPs and store paths on startup - meshagent.js: Use appBundleHashHex for agents with App Bundle capability - views/default.handlebars: Add app bundle UI with installation type dropdown - agents/meshcore.js: App bundle detection and .msh file support Fixes agent installation and self-update hash verification issues. Deprecates mpkg installer in favor of ZIP-based delivery. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
41c02a2 to
1b77dac
Compare
This commit makes two related improvements to macOS installer handling: 1. Remove embedding from bare binary mode (installflags 0-2): - Serve bare binary without embedding for macOS (preserves code signature) - Non-macOS platforms still use embedding as before - Remove deprecated warning from UI 2. Add .msh-only download options (installflags 30-32): - New options: Background & interactive (msh), etc. - Downloads just meshagent.msh configuration file - Shows simple curl command for .msh download - Add &mshonly=1 server-side handler UI Changes (default.handlebars): - Rename installflags 0,1,2 to include "(binary)" suffix - Add new .msh-only options (30, 31, 32) - Detect .msh-only mode (installflags >= 30) - Add bare binary command handler (installflags < 10) - Remove deprecated warning message Server Changes (webserver.js): - Add handler for &mshonly=1 parameter - Serve .msh file directly with text/plain content-type - Add macOS platform check before embedding - Serve bare binary for macOS without embedding 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
The bare binary mode (installflags 0-2) now serves binaries without embedded .msh data to preserve code signatures. Update the install command to download the .msh file separately using the new mshonly endpoint. Changes: - Download binary: curl -o meshagent "URL&installflags=X" - Download .msh: curl -o meshagent.msh "URL&installflags=X&mshonly=1" - Add --copy-msh=1 flag to installation command - Ensures .msh installflags match the selected installation type 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Not a worry. I get that this is a lot but there was a lot to clean up after 3+ years of skipping out on macos. And after talking to Simon, I realized there was a lot to polish still needed, so this MeshCentral pull cleans up the server-side functions
|
webserver.js
Outdated
| if (req.query.sitestyle == 3) { uiViewMode = 'default3'; } | ||
| } else if (webstateJSON && webstateJSON.uiViewMode == 3) { | ||
| uiViewMode = 'default3'; | ||
| else if (req.query.sitestyle == 78) { uiViewMode = 'default78'; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
erm this will break your meshcentral web ui?
the default78 is the file name and the is no default78.handlebars file!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right 78's only on my fork. Should be fixed on ... 2cf8757
These references were accidentally included and would cause errors for users without the default78.handlebars template file. This PR is focused on macOS agent updates, not UI customization.
Sounds very good! I got 2 things, can I still run it with a plain .msh file and a binary next to eachother? And are you willing to support the MacOS Agent longer-term? Like I am doing with Docker :) |
|
@DaanSelen There's a myriad of ways the macOS MeshAgent handles installs and The logic for There is also a "And are you willing to support the MacOS Agent longer-term? Like I am doing with Docker :)" Thats a question. As long as it's in my stack I'll look at it. But I'm not in a place where I can devote anything like the time that I have. It directly affects my ability to support my family. |
Sounds good what is then embedded inside the binary? |
Summary
This PR enhances the macOS agent update process and adds a new installer UI option for deploying macOS agents.
This PR is required for Ylianst/MeshAgent#313 to perform agent updates/self-updates successfully on macOS. The MeshAgent PR introduces improved update mechanisms, and this PR provides the necessary meshcore.js infrastructure to support those updates reliably, plus UI improvements for initial agent deployment.
Key Improvements
MeshCore Improvements
1. Startup Cleanup
meshagent.upgradelaunchctl jobs on agent startup2. darwin_spawn() Function
posix_spawnwrapper via_GenericMarshalfor detached process executionPOSIX_SPAWN_SETPGROUP)launchctloperations that must survive parent process termination3. Enhanced Service Name Handling
serviceIdandserviceNamelookups4. Update Progress Tracking
agentupdatecompleteaction to server on successful update5. macOS-Specific Update Process
launchctl submitto run-upgradeas an isolated launchd job6. App Bundle Support
UI Improvements
1. macOS Binary Installer Option
xattr2. Dynamic Architecture Selection
3. ZIP vs Deprecated Installation Methods
4. Installation Type Options
5. One-Line Install Command
Technical Details
The Three-Layer Protection System
This ensures no accumulation of stuck upgrade processes regardless of where failures occur.
Process Isolation
The
darwin_spawn()function properly detaches child processes usingposix_spawnwith thePOSIX_SPAWN_SETPGROUPflag, creating a new process group. This is critical forlaunchctloperations that must continue running after meshcore restarts during the update.Code Signature Preservation
The ZIP installation method keeps the agent binary clean and stores mesh settings in a separate
.mshfile. This preserves the code signature on macOS, which is important for security and compatibility with macOS security features like Gatekeeper.Testing
MeshCore: Tested on macOS with launchd-managed agents. The update process:
-upgradeas an isolated jobUI: Tested macOS binary installer with:
Changes
agents/meshcore.js,views/default.handlebarsRelated PRs
Notes