It sounds like you are asking two different questions: 1) how can I run 
something before the user login process starts so I can play with the home 
directory, and 2) how can I run something before most of the LaunchDaemons.

        The best answer I know to #1 is to write a AuthenticationPlugin. I had 
to do exactly that a long time ago at Stanford to handle a timing change for 
AFS (Andrew File System) home directories. Normally these are written to do 
things like 2-factor authentication for hardware dongles and the like, but I 
wrote one that always returned OK but made sure that `kinit` and the directory 
caching was good before doing so. I open sourced a version of that, but there 
is no guarantee that it would even still compile on modern MacOS:

https://code.google.com/archive/p/loginwindowtools/ 
<https://code.google.com/archive/p/loginwindowtools/>

        As to #2, you are going to have to be a lot clearer about what you are 
trying to do. Apple’s recommendation for handling startup dependencies is to 
have each tool monitor its dependencies itself, and handle the cases where it 
needs to wait for something. My general approach has been to write a Python 
script in front of each one that has dependencies that waits for them then uses 
something like `execv` to hand over the PID to the real process.
        The earliest documented part where you can launch things is with 
LaunchDaemons, and those are intentionally started in no particular order and 
are expected to deal with non-deterministic state.

> On Sep 16, 2017, at 10:34 AM, Michael <[email protected]> wrote:
> 
> I'd like to know how to run a command at login. Specifically, an hdiutil 
> command to attach a drive image.
> 
> I need this to run from login window, after logging in, but before anything 
> else -- before finder tries to run, can't find the directory, and loses my 
> place; before terminal tries to start up, and puts me in either / or ~ 
> because the directory I was working in is no longer there.
> 
> For that matter, is there any way to get a command run early in bootup? 
> rc.local is late -- too many other daemons have started before it runs (long 
> ago, you could edit /etc/rc and add stuff before the multi-user startup 
> started. Now?)

_______________________________________________
MacOSX-talk mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/macosx-talk

Reply via email to