fleet/orbit/pkg
aysiu b5c0e61f7d
Enable launch daemon before trying to bootstrap it (#22764)
## Description
Moves the enabling of the launch daemon to before trying to launch it,
so it doesn't fail if the launch daemon is disabled

## Testing Done
launch daemon is enabled
```
 launchctl print system | grep fleetdm
		   78074      - 	com.fleetdm.orbit
		"com.fleetdm.orbit" => enabled
```
uninstalling FleetDM via
https://github.com/fleetdm/fleet/blob/main/orbit/tools/cleanup/cleanup_macos.sh
```
sudo ~/Desktop/removefleet.sh 
Removing fleet, system will be unenrolled in 15 seconds...
Executing detached child process
```
launch daemon is still enabled:
```
launchctl print system | grep fleetdm   
		   78074      - 	com.fleetdm.orbit
		"com.fleetdm.orbit" => enabled
```
If I manually disable the launch daemon...
```
sudo launchctl disable system/com.fleetdm.orbit
```
```
launchctl print system | grep fleetdm          
		       0     78 	com.fleetdm.orbit
		"com.fleetdm.orbit" => disabled
```
... then the install will fail:
```
sudo installer -pkg ~/Desktop/fleet-osquery-1.18.3.pkg -target /
installer: Package name is Fleet osquery
installer: Installing at base path /
installer: The install failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An error occurred while running scripts from the package “fleet-osquery-1.18.3.pkg”.)
```
Excerpt from `/var/log/install.log`:
```
2024-10-08 15:00:57-07 HOSTNAME package_script_service[80350]: ./postinstall: Retrying launchctl bootstrap...
2024-10-08 15:00:57-07 HOSTNAME package_script_service[80350]: ./postinstall: Bootstrap failed: 5: Input/output error
2024-10-08 15:00:58-07 HOSTNAME package_script_service[80350]: ./postinstall: Retrying launchctl bootstrap...
2024-10-08 15:00:58-07 HOSTNAME package_script_service[80350]: ./postinstall: Bootstrap failed: 5: Input/output error
2024-10-08 15:00:59-07 HOSTNAME package_script_service[80350]: ./postinstall: Retrying launchctl bootstrap...
2024-10-08 15:00:59-07 HOSTNAME package_script_service[80350]: ./postinstall: Bootstrap failed: 5: Input/output error
2024-10-08 15:01:00-07 HOSTNAME package_script_service[80350]: ./postinstall: Retrying launchctl bootstrap...
2024-10-08 15:01:00-07 HOSTNAME package_script_service[80350]: ./postinstall: Bootstrap failed: 5: Input/output error
2024-10-08 15:01:01-07 HOSTNAME package_script_service[80350]: ./postinstall: Retrying launchctl bootstrap...
2024-10-08 15:01:01-07 HOSTNAME package_script_service[80350]: ./postinstall: Bootstrap failed: 5: Input/output error
2024-10-08 15:01:02-07 HOSTNAME package_script_service[80350]: ./postinstall: Retrying launchctl bootstrap...
2024-10-08 15:01:02-07 HOSTNAME package_script_service[80350]: ./postinstall: Bootstrap failed: 5: Input/output error
2024-10-08 15:01:03-07 HOSTNAME package_script_service[80350]: ./postinstall: Retrying launchctl bootstrap...
2024-10-08 15:01:03-07 HOSTNAME package_script_service[80350]: ./postinstall: Bootstrap failed: 5: Input/output error
2024-10-08 15:01:04-07 HOSTNAME package_script_service[80350]: ./postinstall: Failed to bootstrap system /Library/LaunchDaemons/com.fleetdm.orbit.plist
```
If I then enable the launch daemon...
```
sudo launchctl enable system/com.fleetdm.orbit  
```
```
launchctl print system | grep fleetdm                           
		"com.fleetdm.orbit" => enabled
```
... then the postinstall in the pkg works fine:
```
sudo installer -pkg ~/Desktop/fleet-osquery-1.18.3.pkg -target /
installer: Package name is Fleet osquery
installer: Installing at base path /
installer: The install was successful.
```
So, yeah, the enabling has to be before the launching of the launch
daemon.
2024-10-23 13:54:41 -03:00
..
augeas fleetctl, API, copy updates around host identifiers (#20220) 2024-07-09 10:25:01 -07:00
bitlocker fix formatting of unrecognized BitLocker erorr (#21220) 2024-08-09 11:52:50 -03:00
build Add user agent to Orbit HTTP client (#5429) 2022-05-02 11:03:49 -07:00
constant fix: cleanup tasks for MDM migration updates (#21325) 2024-08-15 17:16:56 -04:00
cryptoinfo Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
dataflatten Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
execuser Support Ubuntu 24.04 with Xorg (by detecting user's DISPLAY environment variable) (#18996) 2024-05-16 08:39:30 -03:00
go-paniclog Fix Fleet Desktop bugs on Windows (#16402) 2024-01-29 18:52:55 -03:00
insecure Make creation of http.Client uniform across the codebase (#3097) 2021-11-24 15:56:54 -05:00
installer Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
keystore Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
logging Reduce orbit logging when the server is down (#16968) 2024-02-21 15:36:15 -03:00
migration fix: add missing comments 2024-08-15 19:00:47 -04:00
osquery Perform early restart before starting sub-systems and minor refactor of orbit sub-systems (#20610) 2024-07-19 12:44:43 -03:00
osservice 8009 fleet desktop icon duplication (#8017) 2022-10-13 10:58:37 -03:00
packaging Enable launch daemon before trying to bootstrap it (#22764) 2024-10-23 13:54:41 -03:00
platform Fix Fleet Desktop bugs on Windows (#16402) 2024-01-29 18:52:55 -03:00
process Fleetctl to package .app bundles for osquery (and changes for orbit to support them) (#4393) 2022-03-15 16:04:12 -03:00
profiles feat: manual MDM migration updates (#21115) 2024-08-08 15:46:42 -04:00
scripts Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
table Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
token Fixing fleetd to NOT make unnecessary duplicate call to orbit/device_token endpoint. (#15543) 2023-12-10 17:00:24 -06:00
update Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
user fix: don't attempt to launch fleet desktop until the user is logged into GUI (#16090) 2024-01-17 10:00:28 -05:00
useraction Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
windows Add Kolide osquery tables 2023-11-01 20:11:35 -06:00