Hi everyone,
I am currently writing a script that configures some things on a freshly installed macOS. For this reason I created the following launch daemon that gets installed via startosinstall on macOS install time.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>de.paviro.launchd-setup</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/setup-utility</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/Library/Logs/PaViRo/output.log</string>
<key>StandardErrorPath</key>
<string>/Library/Logs/PaViRo/error.log</string>
</dict>
</plist>
For some reason this daemon does not get started on the initial boot (when Setup Assistant runs) but only after I reboot the machine.
I also have a LaunchAgent in place that creates a file when the user is logged in.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true/>
<key>Label</key>
<string>de.paviro.launchd-setup-trigger</string>
<key>ProgramArguments</key>
<array>
<string>touch</string>
<string>/tmp/userloggedin</string>
</array>
</dict>
</plist>
Initially I used this file to trigger the daemon via watched paths. As this didn't work on first boot for some reason I tried what I have now and then wait for the file in the setup-utility script.
This also doesn't work on first boot however as the daemon is never run.
The LaunchAgent is run though, the file userloggedin is present after finishing the Setup Assistant process. No logs of the daemon can be found until the Mac has been rebooted in contrast.
If anyone has a hint I would be very grateful!
Best,
Paul