feat(autostart): add LaunchDaemon support for headless macOS servers#4984
feat(autostart): add LaunchDaemon support for headless macOS servers#4984resker wants to merge 1 commit into
Conversation
f2ca93d to
0c20526
Compare
|
@resker May I confirm that your commits were DCO-signed by you human, not by a bot? |
@AkihiroSuda - yes, confirmed... I am not now nor have I ever been a bot :-) The turnaround assisted by AI tools (everything reviewed and submitted by me though). |
Sorry for doubting you 😅 |
AkihiroSuda
left a comment
There was a problem hiding this comment.
Thanks, LGTM after squashing commits.
WIll merge after the release of v2.1.2
|
@resker Could you squash the commits? |
be5c6be to
65d8aa2
Compare
Adds `limactl autostart enable --condition=boot` to register a Lima instance
as a system-level LaunchDaemon. The VM starts at boot without requiring a user
login session, enabling headless macOS server deployments.
Also unifies the existing start-at-login functionality under the new
`limactl autostart` command and deprecates `limactl start-at-login`.
- pkg/autostart/launchd: add DaemonManager, plist template, and helpers
- pkg/autostart/managers.go: add extraTemplateVars field
- pkg/autostart/managers_darwin.go: DaemonManager constructor
- pkg/autostart/managers_{linux,others}.go: unsupported stubs
- cmd/limactl/autostart.go: cross-platform autostart command group
- cmd/limactl/autostart_darwin.go: login → LaunchAgent, boot → LaunchDaemon
- cmd/limactl/autostart_others.go: login only, boot returns unsupported error
- cmd/limactl/start-at-login.go: marked deprecated
- website/content/en/docs/usage/autostart.md: new documentation page
Signed-off-by: Robert Esker <resker@gmail.com>
65d8aa2 to
f3b3abb
Compare
|
@AkihiroSuda - Squashed ( the lints check seems to be a network error in the link-checker). Should #5086 and #5088 (follow up refinements to this) be tagged impact/changelog / milestone v2.2.0 as well? |
Closes #4983
Summary
Adds
limactl autostart enable --condition=bootto register a Lima instanceas a system-level LaunchDaemon. The VM starts at boot without requiring a user
login session, enabling headless macOS server deployments.
Also unifies the existing
start-at-loginfunctionality under the newlimactl autostartcommand and deprecateslimactl start-at-login.Commands
Design
Privilege model:
limactlitself stays non-root (the existing root checkis not bypassed). The
--condition=bootpath execssudointernally forexactly two operations — writing to
/Library/LaunchDaemons/and runninglaunchctl bootstrap system— and prompts for a password once at install time.UserNameplist key: launchd runs the daemon process as the specified user(defaulting to
$USER), so the Lima instance runs under the correct user'shome directory and config without requiring that user to be logged in.
Runtime: the daemon plist calls
limactl start <instance> --foreground,consistent with the existing LaunchAgent approach. Normal
limactl start/stopcontinues to work; no privileged runtime operations are needed.
Changes
pkg/autostart/launchd/io.lima-vm.daemon.INSTANCE.plist— daemon plist templatepkg/autostart/launchd/launchd.go—GetDaemonPlistPath,DaemonServiceNameFrom,DaemonTemplatepkg/autostart/managers.go—extraTemplateVarsfield onTemplateFileBasedManagerpkg/autostart/managers_darwin.go—DaemonManager(userName string)constructorpkg/autostart/managers_linux.go,managers_others.go—DaemonManagerstubscmd/limactl/autostart.go—limactl autostartcommand group (cross-platform)cmd/limactl/autostart_darwin.go— macOS: login → LaunchAgent, boot → LaunchDaemoncmd/limactl/autostart_others.go— non-macOS: login only, boot returns unsupported errorcmd/limactl/start-at-login.go— marked deprecatedcmd/limactl/main.go— registerautostartsubcommandwebsite/content/en/docs/usage/autostart.md— new documentation subpageTesting
GetDaemonPlistPath,DaemonServiceNameFrom, and daemon plist renderingNotes
--condition=bootis macOS only; other platforms return an unsupported errorBy submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license and I have signed off all commits per the DCO.