About Mac OS X Hooks
The Mac OS X Login Window has a built-in mechanism for running scripts or applications during the login or logout process. To enable this mechanism, the Login Window must have two entries added to its preferences, LoginHook and LogoutHook. Mac OS X Hooks does this for you.


Building
Because Mac OS X Hooks is just a collection of scripts, there's nothing to build.

Installing
To install the login and logout hooks, run 'make install' as root. The following scripts will be installed:

/private/etc/login.hook
/private/etc/logout.hook
/private/etc/hooks/masterlogin.sh
/private/etc/hooks/masterlogout.sh

make install also sets two preferences in /Library/Preferences/com.apple.loginwindow.plist:

<key>LoginHook</key>
<string>/etc/login.hook</string>

and

<key>LogoutHook</key>
<string>/etc/logout.hook</string>

This tells the Login Window which items should be run on login and logout.


Building an Installer Package
'make package' as root will build a Mac OS X Installer Package called MacOSXHooks.pkg in the hooks directory. This package can then be installed with Apple's Installer.app or installer command line tool.


How Mac OS X Hooks works
The login.hook and logout.hook check to see if iHook is installed. If it is, iHook runs either masterlogin.sh or masterlogout.sh, depending on whether the user is logging in or out. Otherwise, the scripts are executed without an interface.

When masterlogin.sh is executed, it runs everything in /etc/hooks beginning with LI. For example:

LI00CheckUsername.hook
LI10MountNFS.hook
LI99WelcomeUser.hook

masterlogout.sh runs everything in /etc/hooks beginning with LO. For example:

LO10ClearCaches.hook
LO10UnmountNFS.hook
LO99Radmind.hook

This allows the administrator to add a script to the login or logout process simply by naming the script according to the above conventions, and placing it in /etc/hooks.

To disable individual scripts in /etc/hooks, the administrator can either remove the LI or LO prefix, or delete them from the directory. To disable the login or logout hook in the Login Window, the administrator can execute the following commands:

sudo defaults delete /Library/Preferences/com.apple.loginwindow LoginHook
sudo defaults delete /Library/Preferences/com.apple.loginwindow LogoutHook


Copyright (c) 2004 Regents of The University of Michigan
All Rights Reserved
