LaunchDaemon conflict

endor-moon
Contributor II

Hi Folks,

I have written a launchdaemon and I believe it is executing on first boot. However, I would like to wait until the second boot, as first boot after Casper Imaging, Casper is running its own tasks and I suspect the system is being restarted before my tasks are complete. How do I detect Casper's post-boot activity to avoid this conflict?

Here is the code of my launchdaemon. I called it com.orgname.firstboot instead of my actual institution's name just for illustration here. [Edited this post and removed LaunchOnlyOnce switch. I got some excellent feedback on that already.]

<?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>com.orgname.firstboot</string> <key>Disabled</key> <true/> <key>RunAtLoad</key> <true/> <key>ProgramArguments</key> <array> <string>/Library/AdminToolBox/on-firstboot.sh</string> </array>
</dict>
</plist>

1 ACCEPTED SOLUTION

tron_jones
Release Candidate Programs Tester

Simplest way is to add your LaunchDaemon as a .dmg that is installed on reboot after imaging. This will bypass the initial RunAtLoad. Then after casper runs its on tasks on the first restart have it restart again, triggering your LaunchDaemon.

View solution in original post

4 REPLIES 4

tron_jones
Release Candidate Programs Tester

Simplest way is to add your LaunchDaemon as a .dmg that is installed on reboot after imaging. This will bypass the initial RunAtLoad. Then after casper runs its on tasks on the first restart have it restart again, triggering your LaunchDaemon.

pblake
Contributor III

I agree with @tron_jones

endor-moon
Contributor II

Great idea, tron_jones, thank you. Simple is always best. I will try this out today.

stevewood
Honored Contributor II
Honored Contributor II

Just to clarify, it does not have to be a DMG file. A PKG can be set to load at reboot as well and will perform just as @tron_jones described.