Skip to main content
Solved

LaunchDaemon conflict

  • November 5, 2014
  • 4 replies
  • 33 views

Forum|alt.badge.img+10

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>

Best answer by tron_jones

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.

4 replies

Forum|alt.badge.img+9
  • Contributor
  • Answer
  • November 5, 2014

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.


Forum|alt.badge.img+11
  • Contributor
  • November 6, 2014

I agree with @tron_jones


Forum|alt.badge.img+10
  • Author
  • Valued Contributor
  • November 7, 2014

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


stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • November 7, 2014

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.