From bb0b56acb73f5f5e034d034a2c4bf5f8f53baabb Mon Sep 17 00:00:00 2001 From: Nate Felton Date: Wed, 16 Feb 2022 06:31:16 -0500 Subject: [PATCH] Update postinstall to use more modern launchctl commands (#4179) * Update postinstall to use more modern launchctl comamnds Fixes #3995 * Switching to service-target specifier * Removing unnecessary kill flag --- changes/issue-3995-update-postinstall-launchdaemon | 1 + orbit/pkg/packaging/macos_templates.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changes/issue-3995-update-postinstall-launchdaemon diff --git a/changes/issue-3995-update-postinstall-launchdaemon b/changes/issue-3995-update-postinstall-launchdaemon new file mode 100644 index 0000000000..ae5243406f --- /dev/null +++ b/changes/issue-3995-update-postinstall-launchdaemon @@ -0,0 +1 @@ +* Update macOS package postinstall script to use more modern `launchctl` commands. \ No newline at end of file diff --git a/orbit/pkg/packaging/macos_templates.go b/orbit/pkg/packaging/macos_templates.go index acffd0aec6..3f9de197a7 100644 --- a/orbit/pkg/packaging/macos_templates.go +++ b/orbit/pkg/packaging/macos_templates.go @@ -37,8 +37,17 @@ ln -sf /var/lib/orbit/bin/orbit/macos/{{.OrbitChannel}}/orbit /var/lib/orbit/bin ln -sf /var/lib/orbit/bin/orbit/orbit /usr/local/bin/orbit {{ if .StartService -}} -launchctl unload /Library/LaunchDaemons/com.fleetdm.orbit.plist -launchctl load -w /Library/LaunchDaemons/com.fleetdm.orbit.plist +DAEMON_LABEL="com.fleetdm.orbit" +DAEMON_PLIST="/Library/LaunchDaemons/${DAEMON_LABEL}.plist" + +# Remove any pre-existing version of the config +launchctl bootout "system/${DAEMON_LABEL}" +# Add the daemon to the launchd system +launchctl bootstrap system "${DAEMON_PLIST}" +# Enable the daemon +launchctl enable "system/${DAEMON_LABEL}" +# Force the daemon to start +launchctl kickstart "system/${DAEMON_LABEL}" {{- end }} `))